WebSphere wsadmin testConnection错误消息 [英] WebSphere wsadmin testConnection error message

查看:235
本文介绍了WebSphere wsadmin testConnection错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写脚本来测试WebSphere Cell/Node/Cluster的所有数据源.尽管可以通过管理控制台实现此功能,但对于某些受众来说,脚本是更好的选择.

I'm trying to write a script to test all DataSources of a WebSphere Cell/Node/Cluster. While this is possible from the Admin Console a script is better for certain audiences.

因此,我从IBM

So I found the following article from IBM https://www.ibm.com/support/knowledgecenter/en/SSAW57_8.5.5/com.ibm.websphere.nd.multiplatform.doc/ae/txml_testconnection.html which looks promising as it describles exactly what I need.

拥有基本的脚本后,例如:

After having a basic script like:

ds_ids = AdminConfig.list("DataSource").splitlines()

for ds_id in ds_ids:
  AdminControl.testConnection(ds_id)

我遇到了一些未记录的行为.与testConnection函数上面的文章相反,它并不总是返回String,但可能还会引发异常.

I experienced some undocumented behavior. Contrary to the article above the testConnection function does not always return a String, but may also throw a exception.

所以我只使用try-catch块:

So I simply use a try-catch block:

try:
  AdminControl.testConnection(ds_id)
except: # it actually is a com.ibm.ws.scripting.ScriptingException
   exc_type, exc_value, exc_traceback = sys.exc_info()

现在,当我打印exc_value时,这就是所得到的:

now when I print the exc_value this is what one gets:

com.ibm.ws.scripting.ScriptingException: com.ibm.websphere.management.exception.AdminException: javax.management.MBeanException: Exception thrown in RequiredModelMBean while trying to invoke operation testConnection

现在,无论出什么问题,此错误消息始终是相同的.我测试了身份验证错误,缺少WebSphere变量和缺少驱动程序类. 在管理控制台打印合理的消息时,脚本会继续打印相同的无意义消息.

Now this error message is always the same no matter what's wrong. I tested authentication errors, missing WebSphere Variables and missing driver classes. While the Admin Console prints reasonable messages, the script keeps printing the same meaningless message.

非常奇怪的是,只要我没有捕获到异常并且脚本只是由于错误退出,就会显示描述性的错误消息.

The very weird thing is, as long as I don't catch the exception and the script just exits by error, a descriptive error message is shown.

访问Java异常会导致exc_value.getCause()给出None. 我也看过DataSource MBean,但是由于只有在启动服务器时它们才会存在,因此我很快放弃了.

Accessing the Java-Exceptions cause exc_value.getCause() gives None. I've also had a look at the DataSource MBeans, but as they only exist if the servers are started, I quickly gave up on them.

我希望有人知道如何捕获未捕获到异常时看到的错误消息.

I hope someone knows how to access the error messages I see when not catching the Exception.

预先感谢

推荐答案

毕竟,对AdminControl的研究和测试似乎不过是某些常用MBean的便利外观.

After all the research and testing AdminControl seems to be nothing more than a convinience facade to some of the commonly used MBeans.

因此,我尝试发布了测试连接服务(例如此处的Java示例

So I tried issuing the Test Connection Service (like in the java example here https://www.ibm.com/support/knowledgecenter/en/SSEQTP_8.5.5/com.ibm.websphere.base.doc/ae/cdat_testcon.html ) directly:

    ds_id = AdminConfig.list("DataSource").splitlines()[0]
    # other queries may be 'process=server1' or 'process=dmgr'
    ds_cfg_helpers = __wat.AdminControl.queryNames("WebSphere:process=nodeagent,type=DataSourceCfgHelper,*").splitlines()

    try:
        # invoke MBean method directly
        warning_cnt = __wat.AdminControl.invoke(ds_cfg_helpers[0], "testConnection", ds_id)
        if warning_cnt == "0":
            print = "success"
        else:
            print "%s warning(s)" % warning_cnt

    except ScriptingException as exc:
        # get to the root of all evil ignoring exception wrappers
        exc_cause = exc
        while exc_cause.getCause():
            exc_cause = exc_cause.getCause()
        print exc_cause

这是我所希望的方式.缺点是,如果需要测试在各种作用域(单元/节点/群集/服务器/应用程序)上定义的数据源,则代码将变得更加复杂.

This works the way I hoped for. The downside is that the code gets much more complicated if one needs to test DataSources that are defined on all kinds of scopes (Cell/Node/Cluster/Server/Application).

我不需要这个,所以我把它省略了,但是我仍然希望这个例子对其他人也有用.

I don't need this so I left it out, but I still hope the example is useful to others too.

这篇关于WebSphere wsadmin testConnection错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆