public static void main(String[] args) { try { // Code example that uses the JNDI short form specifying JNDI properties via environment Map // The JNDI environment Map environment = new HashMap(); environment.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.rmi.registry.Regi stryContextFactory"); environment.put(Context.PROVIDER_URL,"rmi://localhost:1099"); // The JNDI short form JMXServiceURL JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://localhost/jndi/jndiPath");
// Connect to the server side JMXConnector connector = JMXConnectorFactory.connect(url, environment); } catch (Exception e) { e.printStackTrace(); } } }
Here is the StackTrace
java.lang.ClassCastException: mx4j.adaptor.rmi.RMIAdaptor_Stub at javax.management.remote.rmi.RMIConnector.narrowJRMPServer(Unknown Source) at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(Unknown Source) at javax.management.remote.rmi.RMIConnector.findRMIServer(Unknown Source) at javax.management.remote.rmi.RMIConnector.connect(Unknown Source) at javax.management.remote.JMXConnectorFactory.connect(Unknown Source) at TestClient.main(TestClient.java:27)