java - Local JMX invokation fails with ClassCastException -


i'm trying invoke jmx service locally using following simple code below. works fine jconsole, under command line throws exception on last line of pasted code.

    string serviceurl = "service:jmx:rmi:///jndi/rmi://localhost:" + configuration.getjmxport();     string[] credentials = new string[]{configuration.getusername(), configuration.getpassword()};     map<string, string[]> attributes = new hashmap<string, string[]>();     attributes.put("jmx.remote.credentials", credentials);      jmxserviceurl jmxurl = new jmxserviceurl(serviceurl);     jmxcon = jmxconnectorfactory.connect(jmxurl, attributes); 

the stack trace looks this:

java.lang.classcastexception: com.sun.jndi.rmi.registry.registrycontext cannot cast javax.management.remote.rmi.rmiserver     @ javax.management.remote.rmi.rmiconnector.narrowjrmpserver(rmiconnector.java:1897)     @ javax.management.remote.rmi.rmiconnector.findrmiserverjndi(rmiconnector.java:1892)     @ javax.management.remote.rmi.rmiconnector.findrmiserver(rmiconnector.java:1856)     @ javax.management.remote.rmi.rmiconnector.connect(rmiconnector.java:257)     @ javax.management.remote.jmxconnectorfactory.connect(jmxconnectorfactory.java:248)     @ com.aaa.aaa.aaa.jmx.aaajmxclient.main(aaajmxclient.java:36) 

i think jmx service url should -

string serviceurl = "service:jmx:rmi:///jndi/rmi://localhost:" + configuration.getjmxport() + "/jmxrmi";


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -