简体   繁体   中英

Find JMX Server URL using JConsole

I'm having problems programmatically connecting to a local JMX server. I doubled checked the JMX server and it seems to fine, but I'm still unable to connect.

However, using JConsole, I have no problems.

Is there anyway to find the correct server URL from JConsole?

By the way, here is the server I'm trying to connect to:

String jmxServer = "service:jmx:rmi:///jndi/rmi://localhost:" + DEFAULT_PORT + "/jmxrmi";

And these are the JVM options I'm launching my process with:

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=DEFAULT_PORT
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false

in your code, you and print out the system property

com.sun.management.jmxremote.localConnectorAddress

which should give you the local connector address.

then from your client something like

final JMXServiceURL jmxURL = new JMXServiceURL(localConnectorAddress);
final JMXConnector connector = JMXConnectorFactory.connect(jmxURL);
final MBeanServerConnection mbsc = connector.getMBeanServerConnection();

should do it... (well does do it, as i done it)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM