最近,在机器人程序中使用jmx,准备做个远程调用,客户端是web,部署在jboss上,本地测试的都好好的,发到预发布上就是不行,
错误描述: Failed to retrieve RMIServer stub: javax.naming.NameNotFoundException: rmi://10.6.54.232:9734/ffmmendservice -- service jboss.naming.context.java.rmi:."10.6.54.232:9734".ffmmendservice
详细信息:
javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:369) javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:270) org.springframework.jmx.support.MBeanServerConnectionFactoryBean$JMXConnectorLazyInitTargetSource.createObject(MBeanServerConnectionFactoryBean.java:188) org.springframework.aop.target.AbstractLazyCreationTargetSource.getTarget(AbstractLazyCreationTargetSource.java:86) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:187) com.sun.proxy.$Proxy81.getMBeanServerConnection(Unknown Source) org.springframework.jmx.support.MBeanServerConnectionFactoryBean$MBeanServerConnectionLazyInitTargetSource.createObject(MBeanServerConnectionFactoryBean.java:205) org.springframework.aop.target.AbstractLazyCreationTargetSource.getTarget(AbstractLazyCreationTargetSource.java:86) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:187) com.sun.proxy.$Proxy83.invoke(Unknown Source)
....
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231) org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) org.jboss.modcluster.container.jbossweb.JBossWebContext$RequestListenerValve.event(JBossWebContext.java:91) org.jboss.modcluster.container.jbossweb.JBossWebContext$RequestListenerValve.invoke(JBossWebContext.java:72) org.jboss.as.web.session.ClusteredSessionValve.handleRequest(ClusteredSessionValve.java:134) org.jboss.as.web.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:99) org.jboss.as.web.session.JvmRouteValve.invoke(JvmRouteValve.java:92) org.jboss.as.web.session.LockingValve.invoke(LockingValve.java:64) org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926) java.lang.Thread.run(Thread.java:745)
开始一直以为是服务端没部好,改了端口什么的,还是不行,仔细看错误,看到service jboss.naming.context.java.rmi:."10.6.54.232:9734".ffmmendservice,怀疑是jboss的问题,果然
解决方法:
修改以下文件
/jboss-eap-6.3/modules/system/layers/base/sun/jdk/main/module.xml
找到path name=...位置,添加一行(红色部分)
<dependencies>
<system export="true">
<paths>
<path name="sun/rmi/server"/>
<path name="com/sun/script/javascript"/>
<path name="jdk/nashorn/api/scripting"/>
...
<path name="com/sun/jndi/dns"/>
<path name="com/sun/jndi/ldap"/>
<path name="com/sun/jndi/url"/>
<path name="com/sun/jndi/url/rmi"/>
<path name="com/sun/jndi/url/corbaname"/>
<path name="com/sun/jndi/url/dns"/>
<path name="com/sun/jndi/url/iiop"/>
<path name="com/sun/jndi/url/iiopname"/>
<path name="com/sun/jndi/url/ldap"/>
<path name="com/sun/jndi/url/ldaps"/>
...
参考文章: