Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private JMXConnector setUpConnection(String server, int jmxPort) {
- try {
- Registry r = LocateRegistry.getRegistry(server, jmxPort);
- HashMap<String, Object> env = new HashMap<String, Object>();
- String[] credentials = {"username", "password"};
- env.put(JMXConnector.CREDENTIALS, credentials);
- env.put("com.sun.jndi.rmi.factory.socket", new SslRMIClientSocketFactory()); // uncomment if needed
- JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + server + ":" + jmxPort + "/jmxrmi");
- return JMXConnectorFactory.newJMXConnector(url, env);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
- java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
- javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake]
- env.put("com.sun.jndi.rmi.factory.socket", new SslRMIClientSocketFactory());
- env.put("com.sun.jndi.rmi.factory.socket", new SslRMIClientSocketFactory());
Add Comment
Please, Sign In to add comment