Guest User

Untitled

a guest
Jan 18th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. private JMXConnector setUpConnection(String server, int jmxPort) {
  2.  
  3. try {
  4.  
  5. Registry r = LocateRegistry.getRegistry(server, jmxPort);
  6.  
  7. HashMap<String, Object> env = new HashMap<String, Object>();
  8.  
  9. String[] credentials = {"username", "password"};
  10. env.put(JMXConnector.CREDENTIALS, credentials);
  11. env.put("com.sun.jndi.rmi.factory.socket", new SslRMIClientSocketFactory()); // uncomment if needed
  12.  
  13.  
  14. JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + server + ":" + jmxPort + "/jmxrmi");
  15. return JMXConnectorFactory.newJMXConnector(url, env);
  16.  
  17. } catch (Exception e) {
  18. e.printStackTrace();
  19. }
  20. return null;
  21.  
  22. }
  23.  
  24. 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:
  25. javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake]
  26.  
  27. env.put("com.sun.jndi.rmi.factory.socket", new SslRMIClientSocketFactory());
  28.  
  29. env.put("com.sun.jndi.rmi.factory.socket", new SslRMIClientSocketFactory());
Add Comment
Please, Sign In to add comment