0

我在编写 jmx 服务器时遇到问题。

我无法绑定到 url [rmi:localhost:9999/server],在以下行中出现异常:

JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:9999/server");
JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(url,null,mbs);
// i get the exception in the next line
cs.start();

顺便说一句,我在 vm 变量中正确定义了端口。

4

1 回答 1

0

我认为您的程序中需要以下代码。

LocateRegistry.createRegistry(9999);

HashMap env = new HashMap();

SslRMIClientSocketFactory csf = new SslRMIClientSocketFactory();

SslRMIServerSocketFactory ssf = new SslRMIServerSocketFactory(); env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, csf); env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE,ssf);JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(url,env,mbs);

于 2012-12-28T04:04:48.640 回答