Reputation: 437
I'm trying to establish a JMX connection to my tomcat instance from a java client using the below code.
JMXServiceURL url = new MXServiceURL("service:jmx:jmxmp://<host>:<port>"); //line 1
JMXConnector jmxc = JMXConnectorFactory.connect(url); //line 2
MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
Where
host = remote machine where my tomcat instance is running
port = jmx enabled port. In my code it is 9840
My tomcat setenv.sh file is edited with below configurations to enable JMX
export CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9840 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
But, when i execute the program, it hangs at line 2.
If i change line 1 as
JMXServiceURL target = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://<host>:<port>/jmxrmi")
to use RMI instead of JMXMP it executes and i'm able to access various MX beans.
So, i'm not able connect if i use JMXMP protocal. I'm able to connect if i use RMI protocol. What might have went wrong when i use JMXMP?
Thanks, nks
Upvotes: 0
Views: 2094
Reputation: 16066
In order to use the JMXMP client, you need to be running the JMXMP Connector Server. It cannot connect to the [default] RMI Connector Server.
Also see this question for a JMXMP agent that you can install into a running server.
Upvotes: 3