I am reusing the answer that I wrote earlier for this question: Can't connect to MBeanServer from Tomcat via jconsole in Java6
It is not complete, but may help:
Suppose you have a JMX server (alias "JMX Agent" alias "JVM that you want to connect to") running on "TARGET MACHINE" with the RMI registry port in "RMI REGISTRY PORT" and the JMX RMI server port in " JMX RMI SERVER PORT ".
Note:
- The RMI registry tells JMX clients where to find the JMX RMI server port; information can be obtained under the
jmxrmi key. - The RMI registry port is commonly known to be set through system properties when starting the JVM.
- The JMX RMI server port is usually not known as the JVM at random (unless other precautions are taken).
The following URI will result in a successful connection (verified)
service:jmx:rmi://<TARGET_MACHINE>:<JMX_RMI_SERVER_PORT>/jndi/rmi://<TARGET_MACHINE>:<RMI_REGISTRY_PORT>/jmxrmi
It looks nasty. Cut it.
This URI is the URL of RFC2609 "Service Protocol URL" (well, this is really a URI, isn't it?)
It consists of:
service - constantjmx:rmi - service type consisting of: abstract jmx type and rmi URL rmi- the rest is sap (service access protocol specification)
sap decomposes into:
//<TARGET_MACHINE>:<JMX_RMI_SERVER_PORT> - ipsite/jndi/rmi://<TARGET_MACHINE>:<RMI_REGISTRY_PORT>/jmxrmi - part of the URL
A well-informed JMX client connects to ipsite to exchange JMX-over-RMI; but what of the JMX client that does not know this port? Patience ...
The URL is broken into:
/jndi/ - This seems to tell the JMX client that he can get search information at the location that followsrmi://<TARGET_MACHINE>:<RMI_REGISTRY_PORT>/jmxrmi - Yes, we get information about the JMX RMI server in the RMI registry under the search key jmxrmi
This is a bit of a horse-drawn carriage, since you must first contact the RMI registry, which is part of the last SLP URL.
After scratching your head, intuitively, try:
service:jmx:rmi://<TARGET_MACHINE>/jndi/rmi://<TARGET_MACHINE>:<RMI_REGISTRY_PORT>/jmxrmi
Yes it works! The JMX RMI server port is well received from the registry. Secondly, the target machine must also be obtained from the registry, thus:
service:jmx:rmi:///jndi/rmi://<TARGET_MACHINE>:<RMI_REGISTRY_PORT>/jmxrmi
Even better, it works too!
Literature:
David Tonhofer Aug 17 '11 at 20:15 2011-08-17 20:15
source share