我正在开发一个自动化框架,并且我遇到了wsadmin
工具的奇怪行为。这个问题在 WAS 6.1、7.0 和 8.0 中是可重现的(我没有尝试过是 8.5)。
我想知道这是否是 wsadmin 中的一个错误(很奇怪,还没有人注意到它,可能是从 WAS 5 开始!)...
示例脚本可以针对任何 WAS 环境安全地执行而不会造成任何损害。
try:
# this line throws WAS exception
AdminConfig.list('NonExistentType')
except:
# exception is being handled
print 'Handled wsadmin exception'
print 'Raising another exception'
# eventually the script throws a non-WAS exception
x = 1/0
如果我理解正确,上面的脚本在零除时失败。但是wsadmin
输出有点混乱:
Handled wsadmin exception
Raising another exception
WASX7017E: Exception received while running file "ex.py"; exception information: com.ibm.websphere.management.exception.InvalidConfigDataTypeException
com.ibm.websphere.management.exception.InvalidConfigDataTypeException: ADMG0007E: The configuration data type NonExistentType is not valid.
真正有趣的是,Jacl 似乎也有同样的问题:
if [catch { puts [$AdminConfig list NonExistentType] } result] {
puts "Handled wsadmin exception"
}
puts "Raising another exception"
set x [expr 1 / 0]
wsadmin
也不会打印有关终止脚本的实际异常的任何信息:
Handled wsadmin exception
Raising another exception
WASX7017E: Exception received while running file "ex.jacl"; exception information: com.ibm.websphere.management.exception.InvalidConfigDataTypeException
com.ibm.websphere.management.exception.InvalidConfigDataTypeException: ADMG0007E: The configuration data type NonExistentType is not valid.
稍微更改两个脚本后(以避免抛出 WAS 异常),两个脚本的输出都是正确的。
try:
# this line does not throw any exception
AdminConfig.list('Cell')
except:
# exception is being handled
print 'Handled wsadmin exception'
print 'Raising another exception'
# eventually the script throws a non-WAS exception
x = 1/0
如果脚本没有抛出/处理 WAS 异常,则输出看起来如预期:
Raising another exception
WASX7017E: Exception received while running file "ex1.py"; exception information: com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
File "<string>", line 9, in ?
ZeroDivisionError: integer division or modulo
与 Jacl 相同:
if [catch { puts [$AdminConfig list Cell] } result] {
puts "Handled wsadmin exception"
}
puts "Raising another exception"
set x [expr 1 / 0]
wsadmin
输出以下内容,这也是意料之中的:
wdrCell(cells/wdrCell|cell.xml#Cell_1)
Raising another exception
WASX7017E: Exception received while running file "ex1.jacl"; exception information: com.ibm.bsf.BSFException: error while eval'ing Jacl expression:
divide by zero
while executing
"expr 1 / 0"
invoked from within
"set x [expr 1 / 0]"
我必须承认一点:我问这个问题的原因是我实际上向 WebSphere Support 报告了这个问题。不过,我对他们的答复并不完全满意。Wsadmin/Jython/Jacl/Python/Tcl 专家:您对此有何看法?
难道我做错了什么?
它是一个错误wsadmin
吗?
这是预期的行为???