Search code examples
webspherewsadminwebsphere-traditional

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


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.


Solution

  • 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.