How do I install (or uninstall) an EAR in WebSphere Application Server v.8.5 via command line, using wsadmin?
Asked Answered
S

2

6

Rather than having to go through the administration console, which is tedious, I would rather install and uninstall my Java application (EAR) via command-line, saved as a short-cut in Windows.

Please note that I am running WebSphere Application Server v8.5 in Windows, so I need the DOS commands, as opposed to the Unix ones.

Superfluid answered 30/11, 2016 at 1:9 Comment(0)
A
4

To run any one-shot command on wsadmin you can do:

wsadmin -lang jython -c <command>

To run a script file of multiple wsadmin commands, you can do:

wsamdin -lang jython -f <script_file_name>

To find out what command to run in order to install your application, install an app once using the AdminConsole, and then on the right side under "Command Assistance" click "View administrative scripting command for last action". This is very powerful and it will show you the wsadmin command for whatever the WAS Admin Console has just done.

For example, when I install an app called myapp.war using the Admin Console and view the command assistance I get this very long command:

AdminApp.install('myapp.ear', '[ -nopreCompileJSPs -distributeApp -nouseMetaDataFromBinary -appname myapp-createMBeansForResources -noreloadEnabled -nodeployws -validateinstall warn -noprocessEmbeddedConfig -filepermission .*\.dll=755#.*\.so=755#.*\.a=755#.*\.sl=755 -noallowDispatchRemoteInclude -noallowServiceRemoteInclude -asyncRequestDispatchType DISABLED -nouseAutoLink -noenableClientModule -clientMode isolated -novalidateSchema -MapModulesToServers [[ myapp_Web myapp.war,WEB-INF/web.xml WebSphere:cell=myCell,node=myNode,server=server1 ]] -MapWebModToVH [[ myapp_Web myapp.war,WEB-INF/web.xml default_host ]]]' ) 

In summary:
Do the operations once in Admin Console to get the wsadmin command the Admin Console itself uses, then copy/paste that command into a script or shortcut or whatever.

Azotemia answered 30/11, 2016 at 16:14 Comment(0)
A
4

Create a text file, say installApplication.py, and insert the two following lines:

AdminApp.install('<path_to_application>/application.ear','[-node nodeName -cell cellName -server serverName]')
AdminConfig.save()

Modify the values in the command according to your server, and save the file. [Note: The above commands are valid for a stand-alone environment].

Create a new file, say installApplication.bat. Add the following command to invoke wsadmin using the above script file:

<path_to_WAS_profile>/bin/wsadmin.bat -lang jython -f <path_to_py_file>/installApplication.py

If administrative security is enabled, you will asked to authenticate when you run the command.


When uninstalling the application, the uninstallApplication.py script looks like:

AdminApp.uninstall('<application_name>')
AdminConfig.save()

And then call it as:

<path_to_WAS_profile>/bin/wsadmin.bat -lang jython -f <path_to_py_file>/uninstallApplication.py

In a network deployment environment, you will likely be deploying your application to a cluster. The installApplication.py script then contains the following code:

AdminApp.install('<path_to_application>/application.ear', '[-cluster cluster1]')
AdminConfig.save()
AdminNodeManagement.syncActiveNodes()

You can then call the wsadmin.bat tool from the Deployment Manager profile folder.

The uninstallation commands remain the same between stand-alone and network deployment environments. Adding the line to synchronize the nodes, we have:

AdminApp.uninstall('<application_name>')
AdminConfig.save()
AdminNodeManagement.syncActiveNodes()
Adamik answered 30/11, 2016 at 7:10 Comment(0)
A
4

To run any one-shot command on wsadmin you can do:

wsadmin -lang jython -c <command>

To run a script file of multiple wsadmin commands, you can do:

wsamdin -lang jython -f <script_file_name>

To find out what command to run in order to install your application, install an app once using the AdminConsole, and then on the right side under "Command Assistance" click "View administrative scripting command for last action". This is very powerful and it will show you the wsadmin command for whatever the WAS Admin Console has just done.

For example, when I install an app called myapp.war using the Admin Console and view the command assistance I get this very long command:

AdminApp.install('myapp.ear', '[ -nopreCompileJSPs -distributeApp -nouseMetaDataFromBinary -appname myapp-createMBeansForResources -noreloadEnabled -nodeployws -validateinstall warn -noprocessEmbeddedConfig -filepermission .*\.dll=755#.*\.so=755#.*\.a=755#.*\.sl=755 -noallowDispatchRemoteInclude -noallowServiceRemoteInclude -asyncRequestDispatchType DISABLED -nouseAutoLink -noenableClientModule -clientMode isolated -novalidateSchema -MapModulesToServers [[ myapp_Web myapp.war,WEB-INF/web.xml WebSphere:cell=myCell,node=myNode,server=server1 ]] -MapWebModToVH [[ myapp_Web myapp.war,WEB-INF/web.xml default_host ]]]' ) 

In summary:
Do the operations once in Admin Console to get the wsadmin command the Admin Console itself uses, then copy/paste that command into a script or shortcut or whatever.

Azotemia answered 30/11, 2016 at 16:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.