About Me

About Me
Working with SOA technologies , implementing solution using IBM BPM , IBM Integration Designer,IBM WODM and IBM DataPower

About me

View Mahesh Dondeti's profile on LinkedIn

upcoming posts on IBM Bluemix,Devops,Worklight,Node js.

Thursday, 20 December 2012

Deploying Application in BPMv7.5 using Scripts(Jacl &Jython)

The WebSphere Application Server wsadmin tool provides the ability to run scripts. The wsadmin tool supports a full range of product administrative activities.
The wsadmin tool supports two scripting languages: Jacl and Jython. Five objects are available when you use scripts:
  • AdminControl: Use to run operational commands.
  • AdminConfig: Use to run configurational commands to create or modify WebSphere Application Server configurational elements.
  • AdminApp: Use to administer applications.
  • AdminTask: Use to run administrative commands.
  • Help: Use to obtain general help.

Jacl

Jacl is an alternate implementation of TCL, and is written entirely in Java code.
The wsadmin tool uses Jacl V1.3.2.

Jython

Jython is an alternate implementation of Python, and is written entirely in Java. The wsadmin tool uses Jython V2.1. The following information is a basic summary of the Jython syntax. In all sample code, the => notation at the beginning of a line represents command or function output.
Procedure:-
In this Post I want to explain the How to deploy the application using command line?

1)First I created a simple Mediation module(MM_Sample) it simply took the message from WMQ and print the message to the console .

Assembly diagram:
 
Mediation Flow:

 

  1. I exported the application as EAR file (MM_SampleApp.ear) to the local file system in my case it is (C:/Users/miracle/Desktop/stuff/ MM_SampleApp.ear)
Note :We can also generate the EAR file from .zip or.jar file using serviceDeploy command tool ,we will discuss this later.(see the end of the blog)

This time I used the Integration Designer to export as EAR file.

Starting the Server using Command:-


If you observe the above diagram here Server was stopped.

Open a command line window and change to the bin directory of the WebSphere Process Server installation profile sub directory
cd <WPS_PROFILE_HOME>\bin
Ex: cd C:\IBM\WID62\pf\wps\bin
I am using the BPMv7.5 so in my case it is
C:\IBM\WebSphere\AppServer\profiles\qbpmaps\bin
Start the Web Sphere Process Server if the server is stopped
a. Open a Command window and change to the bin directory of the WebSphere Process Server installation directory by entering the following command from the command prompt .
cd <WPS_PROFILE_HOME>\bin
Example:cd C:\IBM\WebSphere\AppServer\profiles\qbpmaps\bin



b. Start the server with the ‘startServer’ command by entering the following command from the command prompt.
startServer.bat server1 (or)
startServer server1 -username admin -password admin
Here username:admin, password:admin

 

c.know the Server Status by entering the “serverStatus” command in command prompt
serverStatus server1 (here server1 is name of the server)


 
Use the built-in ‘AdminApp’ object to install the application by entering the following command in the wsadmin prompt. (Remember to use forward slashes when specifying the location of the ear file).
$AdminApp install <WPS_PROFILE_HOME>/bin/sample.ear
In our case :-
<WPS_PROFILE_HOME>=C:/IBM/WebSphere/AppServer/profiles/qbpmaps/
EAR file location= C:/Users/miracle/Desktop/stuff/ MM_SampleApp.ear
 
 
Save the configuration by entering the following command
$AdminConfig save
Start the installed application using wsadmin commands
a. Get the application manager object by entering the following command
set appManager [$AdminControl queryNames type=ApplicationManager,process=<ServerName>,*]
Start the MM_SampleApp using the application manager object by entering the following command
$AdminControl invoke $appManager startApplication MM_SampleApp
b)Use wsadmin script to deploy and start the application by issuing the appropriate command: (enter the command on a single line)
cd <WPS_PROFILE_HOME>\bin
wsadmin.bat –lang jacl –username admin –password admin –f <LAB_FILES>\Admin\installSimpleApp.jacl C:/Users/miracle/Desktop/stuff/ MM_SampleApp.ear
c)Verify the MM_SampleApp is statrted or not in your
admin console.
d)Use wsadmin script to stop and uninstall the application by issuing the appropriate command:
cd <WPS_PROFILE_HOME>\bin
wsadmin.bat –lang jacl –username admin –password admin –f <LAB_FILES>\Admin\uninstallSimpleApp.jacl
Deploy an application using wsadmin client (-lang jython)
Note: The wsadmin client uses jacl as the default scripting language. You need to specify the ‘-lang jython’ parameter to pass the jython scripting commands
1)Start wsadmin scripting client using jython scripting language
a. Open a Command window and change to the bin directory of the WebSphere Process Server profile directory by entering the following command from the command prompt
cd <WPS_PROFILE_HOME>\bin
b. Start the wsadmin client by entering the appropriate command from the command prompt. Ensure you specify username and password parameters if the administrative security is enabled
wsadmin.bat –lang jython –username admin –password admin
2)Use the built-in ‘AdminApp’ object to install the application by entering the following command in the wsadmin prompt. (Remember to use forward slashes when specifying the location of the ear file).
print AdminApp.install('<WPS_PROFILE_HOME>/bin/simple.ear')
3. Save the configuration by entering the following command
AdminConfig.save()
4. Start the installed application using wsadmin commands __ a. Get the application manager object by entering the following command
appManager=AdminControl.queryNames('type=ApplicationManager,process=server1,*')
print appManager
Note: This assumes there is only one node.
Start the MM_SampleApp using the application manager object by entering the following command
AdminControl.invoke(appManager, 'startApplication', 'MM_SampleApp')
5.Verify the MM_SampleApp is started or not in your admin console.
6.Stop the application using wsadmin command by entering the following command under the wsadmin prompt
AdminControl.invoke(appManager, 'stopApplication', 'MM_SampleApp')
7.Uninstall the application by entering the following command under the wsadmin prompt
AdminApp.uninstall('MM_SampleApp')
8.Save the configuration by entering the following command under the wsadmin
 
prompt
AdminConfig.save()
9.Exit wsadmin by entering the following command at the wsadmin prompt
exit
10.Use wsadmin script to deploy and start the application by issuing the appropriate command: (enter the command on a single line)
cd <WPS_PROFILE_HOME>\bin
wsadmin.bat –f <LAB_FILES>\Admin\installSimpleApp.py MM_SampleApp.ear
Use wsadmin script to stop and uninstall the application by issuing the appropriate command:
cd <WPS_PROFILE_HOME>\bin wsadmin.bat –f c:\<LAB_FILES>\Admin\uninstallSimpleApp.py MM_SampleApp 
Create an installable EAR file using serviceDeploy:- 
The serviceDeploy tool allows for the ability to deploy applications (generate and compile) from the command line resulting in a Service Component Architecture (SCA) application .ear file that is good for installing to the WebSphere Process Server runtime. Using the serviceDeploy tool, developers can automate their production builds by invoking scripts for the build process.The archive, upon which the serviceDeploy tool operates, is the only mandatory parameter, and it must be the first parameter to the command. The archive can be a .jar, .zip, or .ear file. For SCA applications, which include SCA component files and possibly J2EE\index.jsp, archive these files into a .jar. For SCA applications that also include separate J2EE modules, for example Web, EJB, or connector modules, archive these files into a .zip. If a .zip if passed to serviceDeploy, it expects to find J2EE modules along with the SCA files. If none exist, you will receive an error. 
Troubleshooting tips: If errors occur while using serviceDeploy, invoke serviceDeploy with optional -keep parameter to keep the temporary eclipse workspace. Note the name of the workspace, during processing of the serviceDeploy command, change to the <workspace>\.metadata subdirectory and view the .log file.
When passing a .jar to serviceDeploy that includes a top-level J2EE folder with possibly a jsp for testing purposes, remember to use the optional –freeform parameter, which copies the J2EE\xxxx files to the most reasonable J2EE staging module.
The following file types can be used as input to the serviceDeploy command:
jar: -The most useful file type for the simplest applications. The resulting .ear file contains a single .jar file and any needed generated staging modules. The .jar file must contain the service module file.
zip (Project Interchange):-You can export from WebSphere Integration Developer an archive file in project interchange format. This format is unique to the Eclipse development. The exported zip archive file must contain exactly one project with the service module file. The resulting .ear file contains any number of modules, depending upon exactly what is in the project interchange.
zip:-You can create a zip archive file containing .jar files, .war files, and .rar files. Exactly one .jar file must contain the service module file. All contained archives become members of the final exported .ear file.
ear:-You can always run the serviceDeploy command against an .ear file as long as exactly one .jar file in the .ear file contains a the service module file.
Complete the instructions below, to invoke the serviceDeploy command line tool and generate an installable SCA application file:
1. Open a command line window and change to the bin directory of the WebSphere Process Server installation profile subdirectory
cd <WPS_PROFILE_HOME>\bin Ex: cd
 C:\IBM\WID62\pf\wps\bin
  1. Invoke the serviceDeploy command-line tool and pass the <LAB_FILES>\MM_SampleApp.jar archive and the –freeform as parameters
  2. Successful completion of the serviceDeploy will result in a MM_SampleApp.ear file in the same subdirectory from which the command was invoked .
    you can find more information about the commands from below link
Component
Action
Business Rules (WebSphere Business Process Manager only)
  • Install the business rules manager
    • configBusinessRulesManager
SCA
  • List SCA modules
    • listSCAModules
  • Start SCA application
    • startApplication
  • Stop SCA application
    • stopApplication
  • Show module details
    • showSCAModule
  • Show and change module properties
    • showSCAModuleProperties
    • modifySCAModuleProperty
  • List imports and exports
    • listSCAImports
    • listSCAExports
  • Show common details of imports and exports, including name, binding name, and the interface name and type
    • showSCAImport
    • showSCAExport
  • Show import binding details
    • showSCAImportBinding
    • showSCAImportEJBBinding
    • showSCAImportHttpBinding
    • showSCAImportJMSBinding
    • showSCAImportMQBinding
    • showSCAImportWSBinding
  • Modify import binding details
    • modifySCAImportEJBBinding
    • modifySCAImportHttpBinding
    • modifySCAImportJMSBinding
    • modifySCAImportMQBinding
    • modifySCAImportSCABinding
    • modifySCAImportWSBinding
  • Show export binding details
    • showSCAExportBinding
    • showSCAExportEJBBinding
    • showSCAExportHttpBinding
    • showSCEExportJMSBinding
    • showSCAExportMQBinding
    • showSCAExportWSBinding
  • Modify export binding details
    • modifySCAExportHttpBinding
    • modifySCAExportJMSBinding
    • modifySCAExportMQBinding
 

No comments:

Post a Comment