【发布时间】:2013-12-10 15:04:07
【问题描述】:
我需要用 groovy 连接到 websphere jmx:主机是输入参数
def urlRuntime = '/jndi/JMXConnector'
def urlBase = 'service:jmx:iiop://' + host
def serviceURL = new JMXServiceURL(urlBase + urlRuntime)
def h = new Hashtable()
h.put(Context.SECURITY_PRINCIPAL, username)
h.put(Context.SECURITY_CREDENTIALS, password)
h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "com.ibm.websphere.management.remote")
def server = JMXConnectorFactory.connect(serviceURL,h).MBeanServerConnection
println server
当我运行这个例子时,我得到了这个例子:
JSAS1480I: Security is not enabled because the ConfigURL property file is not set.
Caught: java.io.IOException: Connector not available: Error during resolve
java.io.IOException: Connector not available: Error during resolve
at com.ibm.websphere.management.remote.WsProvider.newJMXConnector(WsProvider.java:155)
at KonfiguraceSluzebConfig.main(rob-app-task.groovy:59)
我的代码有什么问题?我正在使用 websphere 版本 8.5.5.0
更新
我尝试添加配置文件:
h.put("com.ibm.CORBA.ConfigURL","ssl.client.props");
但异常仍然相同。我不知道如何添加这个文件
更新2
所以经过少量研究后,我发现我需要添加这个论点:
-Dcom.ibm.CORBA.ConfigURL=sas.client.props
-Dcom.ibm.SSL.ConfigURL=ssl.client.props
现在异常 JSAS1480I 已解决,但还有另一个异常:
Caused by: java.lang.ClassCastException: com.ibm.rmi.javax.rmi.PortableRemoteObject incompatible with javax.rmi.CORBA.PortableRemoteObjectDelegate
当我删除此属性时:
h.put(Context.SECURITY_PRINCIPAL, username)
h.put(Context.SECURITY_CREDENTIALS, password)
然后显示带有用户名和密码的弹出窗口。当我输入有效的用户名和密码时,我们有同样的例外:
java.io.IOException: Connector not available: Error during resolve
at com.ibm.websphere.management.remote.WsProvider.newJMXConnector(WsProvider.java:155)
这真的没有告诉我问题出在哪里......不错的 IBM
谁能帮我解决这个问题?
PS:在java中这个例子有效
【问题讨论】:
-
不,我真的不想指定一些我不知道如何创建的文件以及连接器的主要问题
-
也许您的类路径中需要管理客户端 jar? stackoverflow.com/questions/357095/…
-
我已经在路径中有这个库:com.ibm.ws.admin.client_8.5.0.jar com.ibm.ws.orb_8.5.0.jar com.ibm.ws.webservices.thinclient_8。 5.0.jar
-
删除以下行“h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "com.ibm.websphere.management.remote")”时会发生什么。它基本上告诉 JMX 在指定的包中寻找协议提供者(或连接器)。这可能是无法找到连接器的原因。