tags:

views:

562

answers:

1

I've gone through the process on this page to expose the JMX interface of a web application.

I've managed to view the exposed interface on the Tomcat JMX proxy but when I load JConsole and look for the exposed mbean interface I can't find anything related to the attributes and operations exposed.

Thre is no specific entry on jconsole for the web app so I figured it might be under the TOMCAT jmx entry. It's not. (bare in mind, I did manage to see it on the tomcat jmx proxy page).

How can I manage my web application locally? Why is JConsole not showing it?

+1  A: 

I've managed to fix this by doing a few basic steps -

  1. In the webapp context listener contextInitialized method, I instantiated a singleton class that will run and implement the mbean (the servlet itself cannot implement an mbean because it only wakes up to take requests from the server).
  2. The servlet "informs" the singleton of every operation that we want to monitor and the singleton is the one that actually reports this through jmx.
  3. In the singleton I registered with the mbean server with this command:

    ManagementFactory.getPlatformMBeanServer().registerMBean(this, name);

Thats it. (In a nut shell)

Ben
How does your design work when you have to deploy to a cluster (since you have dependencies on a singleton ...)?
Ryan Fernandes
Good Call. actually, my colleague is working on making this solution a cluster friendly one. I'll update when I have the information.
Ben