I have a problem with the catch of exceptions wiht Wsadmin/jython.
This is a snipet of my code: (I know where the error comes from, the point is I want to catch exceptions properly)
...
try :
print '[ABD INFO] Starting application' , app_name
app_mgr = AdminControl.queryNames( 'type=ApplicationManager,process=' \
+ server + ',*' )
AdminControl.invoke(app_mgr, 'startApplication' ,app_name)
print '[ABD INFO] Application' , app_name, 'started'
except:
print "++++++++++++++++++++++++++++++++++++++++++++"
# error_type, error_value, tb = sys.exc_info()
# print error_type, type(error_type)
print "-----------------------------------------"
# print error_value, type(error_value)
print "message:"
# print error_value.message
print "================================================"
print "Traceback:"
print "================================================"
# traceback.print_exception(error_type, error_value, tb)
traceback.print_exc()
print "==========END TRACEBACK========================"
# print_exception
With the try/ except bock do i get the following message:
ABD INFO] Executed command: wsadmin -f C:\IBM\WebSphere\AppServer\optionalLibraries\jython\thuld_wasadmin\deal_with_exception.py
[ABD] WASX7209I: Connected to process "dmgr" on node aib-201684CellManager01 using SOAP connector; The type of process is: DeploymentManager
[ABD] [ABD INFO] Starting application Trade2
[ABD] ++++++++++++++++++++++++++++++++++++++++++++
[ABD] -----------------------------------------
[ABD] com.ibm.ws.scripting.ScriptingException: javax.management.MBeanException: Exception thrown in RequiredModelMBean while trying to invoke operation startApplication org.python.core.PyJavaInstance
[ABD] message:
[ABD] javax.management.MBeanException: Exception thrown in RequiredModelMBean while trying to invoke operation startApplication
[ABD] ================================================
[ABD] Traceback:
[ABD] ================================================
[ABD] org.python.core.PyTraceback
[ABD] ==========END TRACEBACK========================
And this is the error message i get without try /except. You see wiht try/except do i get a differend or not komplet error message. ( the part "com.ibm.ws.webcontainer.exception.WebAppNotLoadedException: Failed to load webapp: Failed to load webapp: Context root /cards/* is already bound. Cannot start application Cards" is missing)
[ABD] WASX7017E: Exception received while running file "C:\IBM\WebSphere\AppServer\optionalLibraries\jython\thuld_wasadmin\deal_with_exception.py" ; exception information: javax.management.MBeanException
[ABD] com.ibm.ws.exception.RuntimeWarning
[ABD] com.ibm.ws.webcontainer.exception.WebAppNotLoadedException: com.ibm.ws.webcontainer.exception.WebAppNotLoadedException: Failed to load webapp: Failed to load webapp: Context root /cards /* is already bound. Cannot start application Cards
[ABD]
So basicly do i have two questions:
1. How do i catch the WebAppNotLoadedException serperatly.
...
except WebAppNotLoadedException:
...
Does not work?!?!
2. How do i get the second part of my errormessage?
(com.ibm.ws.webcontainer.exception.WebAppNotLoadedException: Failed to load ...)
The trick wiht sys.exc_info() just gives me the first part of the error message, not the last part.
Thank you very much.
except com.ibm.ws.webcontainer.exception.WebAppNotLoadedException:
Regards,
Brian
yes I tried, but doesn't worked. Even the attemp to catch Exception (except Exception:) did not worked.
Just have similar problem with you. I catch it with just "except:" and it seems to do the trick.
--Dan
jes i tried, but that is the point. with the gernal except do i catch every Exception but I want to catch certain Exceptions and deal with this exceptions seperatly.
And still the other problem is that i do not get the second part of the errror message with the sys.exe_info()
I too had faced similar kind of problem. I had tried the following sequence of steps and it seemed to handle WAS exceptions
1. In the jython script, import the WAS exception that you wish to handle
from com.ibm.websphere.management.exception import AdminException
2. Altering the try-except block to catch the exception
try :
AdminControl.someFunc()
except *AdminException*, msg:
print "caught the exception:" , msg
3. In the wsadmin script execution statement add option -wsadmin_classpath " \deploytool\itp\plugins\com.ibm.websphere.v61_6.1.0\ws_runtime.jar" as in the example below...
Note: The directory "com.ibm.websphere.v61_6.1.0" is specific to the version that is installed, hence substitute accordingly
wsadmin -lang jython -wsadmin_classpath "C:\Program Files\IBM\WebSphere\AppServer1\deploytool\itp\plugins\com.ibm.websphere.v61_6.1.0\ws_runtime.jar" -f C:\SampScript.py
If you had any other means of resolving this issue, pls post them too
Cheers,
Krish