0

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

user957183
  • 417
  • 3
  • 10
  • 20

1 Answers1

3

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.

Community
  • 1
  • 1
Nicholas
  • 15,916
  • 4
  • 42
  • 66
  • 1
    seems like tomcat does not have native support for JMXMP as per the thread http://stackoverflow.com/questions/11413178/how-to-enable-jmxmp-in-tomcat. The thread suggests to create a 'LifecycleListener' to make tomcat JMXMP enable. Is there any way to achieve this through some configuration entries as in the case JMX-RMI ? – user957183 Apr 22 '16 at 09:23