This tutorial covers about how to deploy , start , stop , uninstall an application in websphere application server (WAS) using the command line tool wsadmin with Jython script. Before that let us see the various administrative tools provided by WebSphere Application Server for application deployment.
1. admin console
The admin console is a browser-based Web application running in the Web container to administer WebSphere Application Server. This console uses Simple Object Access Protocol (SOAP) via HTTP or HTTPS to connect to the admin application in the application server or deployment manager.
2. wsadmin (WebSphere scripting client )
It is a command line tool that is a non-graphical scripting interface that can be used to administer WebSphere Application Server from a command line prompt. It accepts a file of scripted commands or which can be run interactively. For scripting, wsadmin supports the two script languages JACL and jython. .
3. ANT (Another Neat Tool )
You can create build scripts that compile, package, install, and test your application on WebSphere Application Server.
Now let us see the steps for deploying an application (ear) using command line tool wsadmin with Jython script. The simplest deployment scenario is to deploy an application from a desktop to a running base server.
Steps :
Start the application server if the application server is not running
Open a command prompt and change to the application_server_profile_root/bin directory
To check the status of the server
serverStatus.sh server1
If the server is stopped , then start the server with the below command
startServer.sh server1
a) Save the below lines written using jython script in a file (for example : deploy.jython)
b) Change the first two lines with your suitable values in the script file, save the script file and run it using the below command that will deploy the ear.
wsadmin.sh -f script_file -lang jython
e.g. in linux : $wsadmin.sh -f deploy.jython -lang jython
e.g. in windows : app_profile_root\ bin> wsadmin.bat -f deploy.jython -lang jython
To complete & repeat the above task using admin console , you have to do many steps every time. But using wsadmin , this task can be repeated any number of times using the above single line whenever the application gets modified.
If the application is already not installed , you may get the error application does not exist . Then you may comment (#) the below lines in the script file.
print AdminApp.uninstall(appName)
AdminConfig.save()
1. admin console
The admin console is a browser-based Web application running in the Web container to administer WebSphere Application Server. This console uses Simple Object Access Protocol (SOAP) via HTTP or HTTPS to connect to the admin application in the application server or deployment manager.
2. wsadmin (WebSphere scripting client )
It is a command line tool that is a non-graphical scripting interface that can be used to administer WebSphere Application Server from a command line prompt. It accepts a file of scripted commands or which can be run interactively. For scripting, wsadmin supports the two script languages JACL and jython. .
3. ANT (Another Neat Tool )
You can create build scripts that compile, package, install, and test your application on WebSphere Application Server.
Although the admin console is easy to use and sufficient for tasks that are simple , non-repetitive and having a minimal number of administrative steps. For administrative task that requires many steps, which can be repetitive, and also time consuming , wsadmin is the right tool. wsadmin accepts a file of scripted commands or which can be run interactively. For scripting, wsadmin supports two script languages JACL and jython. WebSphere Application Server installation has a bin directory that contains the wsadmin command . The default connection of wsadmin to connect to the Mbeans is SOAP with the default port 8879. You can also start wsadmin with the different port with -port argument
Now let us see the steps for deploying an application (ear) using command line tool wsadmin with Jython script. The simplest deployment scenario is to deploy an application from a desktop to a running base server.
Steps :
Start the application server if the application server is not running
Open a command prompt and change to the application_server_profile_root/bin directory
To check the status of the server
serverStatus.sh server1
If the server is stopped , then start the server with the below command
startServer.sh server1
a) Save the below lines written using jython script in a file (for example : deploy.jython)
earLoc='path and filename of your ear file' #eg. '/root/Desktop/sales.ear' appName='your application name' # eg. 'salesWeb' cellName=AdminControl.getCell() nodeName=AdminControl.getNode() appManager=AdminControl.queryNames('cell='+cellName+',node='+nodeName+',type=ApplicationManager,process=server1,*') print appManager #AdminControl.invoke(appManager , 'stopApplication',appName) print AdminApp.uninstall(appName) AdminConfig.save() print AdminApp.install(earLoc) AdminConfig.save() AdminControl.invoke(appManager , 'startApplication',appName)
b) Change the first two lines with your suitable values in the script file, save the script file and run it using the below command that will deploy the ear.
wsadmin.sh -f script_file -lang jython
e.g. in linux : $wsadmin.sh -f deploy.jython -lang jython
e.g. in windows : app_profile_root\ bin> wsadmin.bat -f deploy.jython -lang jython
To complete & repeat the above task using admin console , you have to do many steps every time. But using wsadmin , this task can be repeated any number of times using the above single line whenever the application gets modified.
If the application is already not installed , you may get the error application does not exist . Then you may comment (#) the below lines in the script file.
print AdminApp.uninstall(appName)
AdminConfig.save()
This comment has been removed by the author.
ReplyDeleteHi,
ReplyDeleteWhile trying out your code, I am getting error as follows,
WASX7017E: Exception received while running file "D:\PROJECTS_WRKNG\Websphere_Scripts\deploy.py"; exception information: com.ibm.ws.scripting.ScriptingException: WASX7109E: Insufficient data for install task "BindJndiForEJBNonMessageBinding
ADMA0002E: A validation error occurred in task Binding enterprise Bean to JNDI names. The Java Naming and Directory Interface (JNDI) name is not specified for enterprise bean {1}in module {2}.
Please help me out
Thanks,
vamsee
First of all, BRILLIANT
ReplyDeletesecond of all, how would I add precompile jsps to this script?
hi I am getting this error..please help me out.
ReplyDeleteWASX7209I: Connected to process "dmgr" on node DmgrNode01 using SOAP connector;
The type of process is: DeploymentManager
WASX7011E: Cannot find file "deploy.jython"