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?
I've managed to fix this by doing a few basic steps -
- 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).
- 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.
In the singleton I registered with the mbean server with this command:
ManagementFactory.getPlatformMBeanServer().registerMBean(this, name);
Thats it. (In a nut shell)