簡體   English   中英

wsadmin腳本中未處理的異常后的誤導性錯誤消息

[英]Misleading error message after unhandled exception in wsadmin script

我正在開發一個自動化框架,並且遇到了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支持。 我對他們的答復並不完全滿意。 Wsadmin / Jython / Jacl / Python / Tcl專家:您對此有何看法?

難道我做錯了什么?

這是wsadmin的錯誤嗎?

它是預期的行為嗎???

該問題將在即將推出的WSAS 6.1、7.0、8.0和8.5修訂包中得到解決。

IBM支持人員有點擔心破壞與以前的實現的兼容性(這是有爭議的,但是某些腳本可能依賴於此錯誤),因此需要使用com.ibm.ws.scripting.exceptionPropagation=thrown JVM明確啟用適當的行為。屬性。

我知道將屬性傳遞給wsadmin的JVM的兩種方法:

  • javaOption環境變量
  • javaoption選項

環境變量的方式:

export javaOption=-Dcom.ibm.ws.scripting.exceptionPropagation=thrown
./wsadmin.sh -lang jython -f script.py

命令行選項方式:

./wsadmin.sh -javaoption -Dcom.ibm.ws.scripting.exceptionPropagation=thrown-lang jython -f script.py

該修復程序解決了Jython和Jacl的問題。

鏈接到官方文檔: http : //www-01.ibm.com/support/docview.wss?uid=swg1PM80400

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM