WLContext.close() is probably not the real problem (it's even in some of the Oracle examples). What error messages do you see when deploy and undeploy are being called?
You should see something like:
Deploying application from /tmp/something/myapp.ear
Current Status of your Deployment:
Deployment command type: deploy
Deployment State : completed
Deployment Message : no message
I also see that you never call activate()
at the very end of your script so that could be the issue if you are running in production mode.
Try adding the following at the very end of your script after deployMain()
:
save()
status = activate(300000, "block='true'")
status.getStatusByServer()
status.getDetails()
UPDATE:
The activation error occurs because you have not called edit() before the undeploy:
# Get edit/lock for upcoming changes
edit()
startEdit(120000, 120000, 'false')
undeployApplication()
I think you will be better off greatly simplifying your undeploy. You don't need to go through the complexity of determining targets because you are already undeploying from ALL targets. Try this instead and see if you can make progress:
cd ('AppDeployments')
myapps=cmo.getAppDeployments()
for appName in myapps:
try:
appPath = "/AppDeployments/" + appName.getName()
cd(appPath)
print "Stopping deployment " + appName.getName()
stopApplication(appName.getName())
print "Undeploying " + appName.getName()
undeploy(appName.getName(), timeout=60000)
except Exception , e:
print "Deployment " + appName.getName() + " removal failed."