Stop applications with scripting
You can stop applications using the wsadmin tool and scripting. Before starting this task, the wsadmin tool must be running. See the Start the wsadmin scripting client article for more information.
Overview
The following example stops all running applications on a server:
Procedure
- Identify the application manager MBean for the server where the application resides, and assign it to the appManager variable.
- Use Jacl:
set appManager [$AdminControl queryNames cell=mycell,node=mynode,type= ApplicationManager,process=server1,*]
- Use Jython:
appManager = AdminControl.queryNames('cell=mycell,node=mynode,type= ApplicationManager,process=server1,*') print appManagerwhere:
set Jacl command appManager variable name $ Jacl operator for substituting a variable name with its value AdminControl object that enables the manipulation of MBeans running in a WebSphere server process queryNames AdminControl command cell=mycell,node=mynode,type= ApplicationManager,process=server1 hierarchical containment path of the configuration object Jython command
This command returns the application manager MBean. Example output:
WebSphere:cell=mycell,name=ApplicationManager,mbeanIdentifier=ApplicationManager, type=ApplicationManager,node=mynode,process=server1
- Query the running applications belonging to this server and assign the result to the apps variable.
- Use Jacl:
set apps [$AdminControl queryNames cell=mycell,node=mynode,type=Application, process=server1,*]
- Use Jython:
# get line separator import java.lang.System as sys lineSeparator = sys.getProperty('line.separator') apps = AdminControl.queryNames('cell=mycell,node=mynode,type=Application, process=server1,*').split(lineSeparator) print appswhere:
set Jacl command apps variable name $ Jacl operator for substituting a variable name with its value AdminControl object that enables the manipulation of MBeans running in a WebSphere server process queryNames AdminControl command cell=mycell,node=mynode,type= ApplicationManager,process=server1 hierarchical containment path of the configuration object Jython command
This command returns a list of application MBeans. Example output:
WebSphere:cell=mycell,name=adminconsole,mbeanIdentifier=deployment.xml #ApplicationDeployment_1,type=Application,node=mynode,Server=server1, process=server1,J2EEName=adminconsole WebSphere:cell=mycell,name=filetransfer,mbeanIdentifier=deployment.xml #ApplicationDeployment_1,type=Application,node=mynode,Server=server1, process=server1,J2EEName=filetransfer
- Stop all the running applications.
- Use Jacl:
foreach app $apps { set appName [$AdminControl getAttribute $app name] $AdminControl invoke $appManager stopApplication $appName}
- Use Jython:
for app in apps: appName = AdminControl.getAttribute(app, 'name') AdminControl.invoke(appManager, 'stopApplication', appName)This command stops all the running applications by invoking the stopApplication operation on the MBean, passing in the application name to stop.
Results
Once you complete the steps for this task, all running applications on the server are stopped.
Use the AdminControl object for scripted administration
Start applications with scripting
Related Reference
Commands for the AdminControl object