使用groovy连接到websphere jmx时发生连接器错误
我需要使用groovy连接到webspherejmx:host是输入参数使用groovy连接到websphere jmx时发生连接器错误,groovy,websphere,jmx,Groovy,Websphere,Jmx,我需要使用groovy连接到webspherejmx:host是输入参数 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(
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)
我的代码有什么问题?Iam使用websphere版本8.5.5.0
更新
我尝试添加配置文件:
h.put("com.ibm.CORBA.ConfigURL","ssl.client.props");
但例外仍然是一样的。我不知道如何在那里添加这个文件
更新2
因此,在做了一些研究之后,我发现我需要在groovy中添加以下论点:
-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
java.io.IOException: Connector not available: Error during resolve
at com.ibm.websphere.management.remote.WsProvider.newJMXConnector(WsProvider.java:155)
删除此属性时:
h.put(Context.SECURITY_PRINCIPAL, username)
h.put(Context.SECURITY_CREDENTIALS, password)
然后显示带有用户名和密码的弹出窗口。当我输入有效的用户名和密码时,我们有相同的例外:
Caused by: java.lang.ClassCastException: com.ibm.rmi.javax.rmi.PortableRemoteObject incompatible with javax.rmi.CORBA.PortableRemoteObjectDelegate
java.io.IOException: Connector not available: Error during resolve
at com.ibm.websphere.management.remote.WsProvider.newJMXConnector(WsProvider.java:155)
这并没有告诉我问题出在哪里。。。不错的IBM
有人能帮我解决这个问题吗
PS:在java中,这个例子很有效当我通过
jmx
连接Websphere8.5
时,我遇到了与您相同的情况
我反编译了com.ibm.ws.admin.client_8.5.0
,并调试了com.ibm.websphere.management.remote.WsProvider类的源代码
当代码在initialContext.lookup(JNDIROL)行运行时代码>,引发了异常!然后我看了一下异常的细节,我发现了异常的情况:
“连接器不可用:解析期间出错”是“WsnNameService属性[根异常为org.omg.CORBA.TRANSIENT:初始和转发IOR不可访问vmcid:IBM次要代码:E07已完成:否]”
我继续挖掘异常的案例IBM次要代码:E07 completed:No
wasjava.net.UnknownHostException
我发现我在localhost
连接到远程jmx
,目标主机名不在我的hosts文件中。
我将10.24.16.xx remotehostname
添加到hosts文件中,然后运行该程序,它就可以工作了
我希望这对你有用 这有用吗?不,我真的不想指定一些我不知道如何创建的文件,以及ConnectorManager的主要问题。您是否需要在类路径中使用管理客户端jar?我在路径中已经有了这个库: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_包,“com.ibm.websphere.management.remote”)”时会发生什么。它基本上告诉JMX在指定的包中查找协议提供程序(或连接器)。这可能是找不到连接器的原因。