我正在研究用于从多个安全JMX服务器中获取数据的原型应用程序。我正在使用自定义ssl rmi工厂,该工厂使用适当的信任库和密钥库创建套接字。但是,JMX连接器存根不会调用它。
相反,我在客户端应用程序中收到此错误
java.rmi.ConnectIOException: non-JRMP server at remote endpoint
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:248)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:130)
at javax.management.remote.rmi.RMIServerImpl_Stub.newClient(Unknown Source)
at javax.management.remote.rmi.RMIConnector.getConnection(RMIConnector.java:2404)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:308)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:270)
at Client.main(Client.java:86)
服务器
HashMap env = new HashMap();
SslRMIServerSocketFactory ssf = new SslRMIServerSocketFactory();
env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE,ssf);
JMXServiceURL url = new JMXServiceURL( "service:jmx:rmi:///jndi/rmi://localhost:9999/server");
JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
System.out.println("\nStart the RMI connector server");
cs.start();
客户
HashMap env = new HashMap();
SslRMIClientSocketFactory csf1 = new CustomSslRMIClientSocketFactory();
RMIClientSocketFactory csf2 = RMISocketFactory.getDefaultSocketFactory();
env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, csf1);
env.put("com.sun.jndi.rmi.factory.socket", csf2);
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:9999/server");
JMXConnector jmxc = JMXConnectorFactory.connect(url, env);
System.out.println("connection id " + jmxc.getConnectionId());
运行原型应用程序的步骤