tags:

views:

984

answers:

2

Hello All,
I am connecting to tomcat over JMX. I wrote a simple JMX client to connect to tomcat and read different JMX MBean attributes to monitor tomcat. My problem is, I would like to know which port tomcat's HTTP connector is listenting. Is there a way to get this details over JMX Mbean - without reading the server.xml file of tomcat. But to get it thru some attributes of one MBean ?

A: 

The MBean is called something like Catalina:type=ThreadPool,name=http-8080. As you can see the connector port is in the name.

Kees de Kooter
If the tomcat is not running on 8080, and it is running on 9090 - then the name of the bean will become Catalina:type=ThreadPool,name=http-9090. In that case, I need to know which port the http connector is running.
Shamik
In that case it is running on port 9090. The name of the threadpool reflects the port of the http conector.
Kees de Kooter
Probably one stupid question - but my question is - is there any way to know the names of the beans programatically that tomcat exposes ?
Shamik
You can use the JConsole utility to inspect all MBeans of a running application.
Kees de Kooter
You can get a list of MBeans matching various criteria using the `MBeanServerConnection.queryNames()` method. For example, `queryNames(new ObjectName("Catalina:type=ThreadPool,*", null))` should return a list of all the `ThreadPool` MBeans.
Matt Solnit
A: 

Shamik, I'm trying to create a community resource to help everyone learn how to connect tomcat jmx but right now there is no content. Please contribute!