我是 JMX 的新手,正在尝试创建一个简单的示例。我正在创建基本的 JMX 应用程序。我有执行以下操作的 Server.java:
JMXServiceURL url = new JMXServiceURL(
"service:jmx:rmi:///jndi/rmi://localhost:9999/server");
JMXConnectorServer cs =
JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
// Start the RMI connector server
echo("\nStart the RMI connector server");
cs.start();
并在 cs.start() 上收到以下错误消息。
java.io.IOException: Cannot bind to URL [rmi://localhost:9999/server]: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect]
at javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:804)
at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:417)
at Server.main(Server.java:93)
Caused by: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect]
at com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:126)
at com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:208)
at javax.naming.InitialContext.bind(InitialContext.java:400)
at javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:625)
at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:412)
在我的 glassfish 服务器中,我添加了以下属性:
-Dcom.sun.management.jmxremote.ssl.need.client.auth=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.port=9999
请告诉我缺少什么。
编辑:
也在使用 RMI 服务器执行时..
-Dcom.sun.management.jmxremote.port=9999'
RMI 服务器上的命令,我收到以下错误:C:\Program Files\Java\jdk1.6.0_17\bin>java -Dcom.sun.management.jmxremote.port=9999 Error: Password file not found: C:\Program Files\Java\jdk1.6.0_17\jre\lib\management\jmxremote.password