Search code examples
tomcatjmxmbeans

How to get to the same JMX MBean server from within 2 Tomcats


i'm a bit of a noob with JMX and servers... I have a multi-node configuration (basically 2 nodes) and i'm creating and registering MBeans on the MBeanServer in both of them. The problem is the MBeanServers are different for my 2 Tomcat servers, whereas i want one global JMX server, so i can see all the MBeans at once.

For the main node i've added these options to the JVM settings:

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

But if i use the same settings for the second node it will tell me the port is already in use, which is kind of normal. If i don't use any such settings it will just create its own server. Btw, i'm getting the MBeanServer reference with ManagementFactory.getPlatformMBeanServer() Is there another way i should connect to the initially created server?

Thanks, Teo


Solution

  • MBeanServer is just a fancy name of a bunch of RMI methods. It is basically a JVM add-on, not a standalone server or process. If you have two different JVMs, you have two MBeanServers, period. If you want to monitor both using JMX, you need some sort of management console/proxy that will connect to both MBeanServers and collect data from both of them.