How to manage a JMX web application

2019-07-31 16:13发布

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?

标签: java tomcat jmx
1条回答
爷、活的狠高调
2楼-- · 2019-07-31 16:59

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)

查看更多
登录 后发表回答