Stop and uninstall an application using wsadmin
Posted by eichelgartenweg on 12:14 PM with 2 comments
Before the application can be unsinstalled it must be stopped.
Steps:
1. Open wsadmin (with jython)
1.1 Go to "WebSphere_Profile_Root"/bin
1.2 Execute
2. Define needed cell and node variables
2. Execute
4.1 Execute
5.1 Execute
6.1 Execute
7.1 Execute
8.1 Execute
Steps:
1. Open wsadmin (with jython)
1.1 Go to "WebSphere_Profile_Root"/bin
1.2 Execute
wsadmin.sh(.bat) -lang jython
1.3 Enter UserID/Password (if promted)2. Define needed cell and node variables
2. Execute
cell=AdminConfig.list('Cell')
cellname=AdminConfig.showAttribute(cell,'name')
nodes=AdminConfig.list('Node',cell)
nodename=AdminConfig.showAttribute(nodes,'name')
-----------------------------------
(Alternative:
e.g.: nodename=NAME_OF_NODE)
3.1 Executcellname=AdminConfig.showAttribute(cell,'name')
nodes=AdminConfig.list('Node',cell)
nodename=AdminConfig.showAttribute(nodes,'name')
-----------------------------------
(Alternative:
e.g.: nodename=NAME_OF_NODE)
3. Define application manager variable
appManager=AdminControl.queryNames
('type=ApplicationManager,cell='+cellname+',
node='+nodename+',process=<APP_SERVER_NAME>,*')
3.2 To print out variable execute('type=ApplicationManager,cell='+cellname+',
node='+nodename+',process=<APP_SERVER_NAME>,*')
print appManager
4. Assign application to variable4.1 Execute
app=AdminControl.queryNames
('type=Application,cell='+cellname+',node='+nodename+',
process=<APP_SERVER_NAME>,J2EEName=<NAME_OF_APPLICATION>,*')
4.2 To print out variable execute('type=Application,cell='+cellname+',node='+nodename+',
process=<APP_SERVER_NAME>,J2EEName=<NAME_OF_APPLICATION>,*')
print app
5. Define application name to variable5.1 Execute
appName=AdminControl.getAttributes(app,'name')
5.2 To print out variable executeprint appName
6. Stop application6.1 Execute
AdminControl.invoke(appManager,'stopApplication', appName)
7. Uninstall application7.1 Execute
AdminApp.uninstall(appName)
8. Save changes8.1 Execute
AdminConfig.save()
Hint:
It is easier to use administrative console :-)
<APP_SERVER_NAME> = Name of server (JVM) where the application is deployed
<NAME_OF_APPLICATION> = Name of the application (not the ear-files name)
Links:
Stop Application [IBM]
Uninstall Application [IBM]
It is easier to use administrative console :-)
<APP_SERVER_NAME> = Name of server (JVM) where the application is deployed
<NAME_OF_APPLICATION> = Name of the application (not the ear-files name)
Links:
Stop Application [IBM]
Uninstall Application [IBM]
Which version of AppServer is it?
ReplyDeleteimport sys
ReplyDeletedef uninstallAndinstallApp(aPath, aServer, aDisplayName):
print 'Application ['+aDisplayName+'] will be uninstalled and then again installed'
print 'Uninstalling in progress...'
try:
AdminApp.uninstall(aDisplayName)
AdminConfig.save()
except:
print 'Application'+aDisplayName+'is not installed. Skipping uninstall step'
print 'Now trying to install...'
AdminApp.install(aPath,'[-server '+aServer+' ]')
AdminConfig.save()
appManager = AdminControl.queryNames('type=ApplicationManager,process='+aServer+',*')
AdminControl.invoke(appManager,'startApplication',aDisplayName)
print "Deploy application started"
appPath = '/tmp/XXXEAR.ear'
serverName = 'server1'
appName = 'XXXEAR'
uninstallAndinstallApp(appPath,serverName,appName)
print "Deploy application PPerson ended."
this works fine on WAS 5.1 without stopping application
You can see log:
Application [XXXEAR] will be uninstalled and then again installed
Uninstalling in progress...
ADMA5017I: Uninstallation of PPersonEAR started.
ADMA5104I: Server index entry for XXX was updated successfully.
ADMA5102I: Deletion of config data for XXXEAR from config repository completed successfully.
ADMA5011I: Cleanup of temp dir for app PPersonEAR done.
ADMA5106I: Application PPersonEAR uninstalled successfully.
Now trying to install...
ADMA5016I: Installation of PPersonEAR started.
ADMA5005I: Application PPersonEAR configured in WebSphere repository
ADMA5001I: Application binaries saved in /ibm/WebSphere/AppServer/wstemp/Script11f88e8f098/workspace/cells/XXX/applications/XXXEAR.ear/XXXEAR.ear
ADMA5011I: Cleanup of temp dir for app XXXEAR done.
ADMA5013I: Application XXXEAR installed successfully.
Deploy application XXX ended.