I need code which could handling the exception and continue the process. but the error handling routine seems unable to get the correct error message:
without exception handling:
wsadmin>AdminControl.testConnection (SomeDataSource)
WAS7015E: Exception Running command: "AdminControl.testConnection (SomeDataSource)"
com.ibm.websphere.management.exception.AdminException
javax.management.MBeanException
java.lang.ClassNotFoundException: java.lang.ClassNotFoundException: DSRA8000E: Java archive (JAR) or compressed files do not exist in the path or the required access is not allowed. Path: /ojdbc6.jar
with exception handling:
wsadmin>try:
wsadmin> AdminControl.testConnection (SomeDataSource)
wsadmin>except:
wsadmin> typ,val,tb = sys.exc_info()
wsadmin> print typ
wsadmin> print val
wsadmin> print tb
com.ibm.ws.scripting.ScriptingException
com.ibm.ws.scripting.ScriptingException: com.ibm.websphere.management.exception.AdminException: javax.management.MBeanException: Exception thrown in RequiredModelMBean while trying to invoke operation testConnection
<traceback object at -1765990050>
Another version (although i believe there should be smarter way to perform it)
wsadmin>fname='${Server log folder}\SystemOut.log'
wsadmin>file=open(fname,'r')
wsadmin>junk=file.readlines()
wsadmin>file.seek(-1,1)
wsadmin>try:
wsadmin> AdminControl.testConnection (SomeDataSource)
wsadmin>except:
wsadmin> err='yes'
wsadmin>
wsadmin>file.seek(1,1)
wsadmin>if err='yes':
wsadmin> msg=file.readlines()
wsadmin> print 'Error: '.join(msg)
Seems i finally get the thing i want, although it is really ugly by skipping the entire error handling but directly getting the content of error log.
I don't know why in wsadmin jython it happens, but you can try this:
There are the results:
Note sys.exc_info()[1]
Regards