我需要代码,它可以处理异常并继续这个过程。但是,错误处理例程似乎无法获得正确的错误消息:
毫无例外地处理:
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异常处理:
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>另一个版本(虽然我认为应该有更聪明的方法来执行它)
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)似乎我终于得到了我想要的东西,尽管它跳过了整个错误处理,但是直接获得了错误日志的内容。
发布于 2014-01-14 20:22:14
我不知道为什么在wsadmin jython中会发生这种情况,但是您可以尝试这样做:
try:
SomeDataSource = "Test"
AdminControl.testConnection (SomeDataSource)
except:
typ,val,tb = sys.exc_info()[1]
print typ
print val
print tb结果如下:
wsadmin>try:
wsadmin> SomeDataSource = "Test"
wsadmin> AdminControl.testConnection (SomeDataSource)
wsadmin>except:
wsadmin> typ,val,tb = sys.exc_info()[1]
wsadmin> print typ
wsadmin> print val
wsadmin> print tb
wsadmin>
WASX7015E: Exception running command: ""; exception information:
com.ibm.ws.scripting.ScriptingException: AdminControl service not available注sys.exc_info()1
问候
https://stackoverflow.com/questions/20868819
复制相似问题