我在使用JBOSS 7.x的JMX连接到Tigase时遇到问题 对于连接,我使用下一个代码:
import java.util.Hashtable;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
JMXServiceURL u = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + HOST_NAME + ":" + PORT + "/jmxrmi");
Hashtable<String, Object> env = new Hashtable<String, Object>();
String[] credentials = new String[] {"login","pass"};
env.put(JMXConnector.CREDENTIALS, credentials);
JMXConnector jmxConnector = JMXConnectorFactory.connect(u, env);
在tigase init.properties中我添加了
--monitoring=jmx:9050,http:9080,snmp:9060
在我添加的java选项的tigase start脚本中
-Dcom.sun.management.jmxremote
-Djava.rmi.server.hostname=< tigase host name >
有趣的是,这一切都是从简单的java应用程序开始,但是从jboss开始不起作用
我使用java openJDK7和JBOSS AS 7.0.2,当我尝试创建连接时,我在JMXConnectorFactory.connect(u,env)上出现下一个错误:
java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.NameNotFoundException: rmi://localhost:9050/jmxrmi -- service jboss.naming.context.java.rmi:."localhost:9050".jmxrmi
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:357)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:267)
at com.mypackage.tigase.JMXTigaseConnector.checkConnection(JMXTigaseConnector.java:61)
at com.mypackage.db_interlayer.StatusLayer.getListTaskStatus(StatusLayer.java:133)
at com.mypackage.servlets.DashBoardServlets.doGet(DashBoardServlets.java:136)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
at com.mypackage.servlets.LoginFilter.doFilter(LoginFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
at java.lang.Thread.run(Thread.java:722)
Caused by: javax.naming.NameNotFoundException: rmi://localhost:9050/jmxrmi -- service jboss.naming.context.java.rmi:."localhost:9050".jmxrmi
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:178)
at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:113)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:214)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1924)
at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1891)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:274)
... 22 more
所以,我不明白为什么会这样。其他人遇到过这个问题?怎么解决?
此致,Marina。