How to manage a JMX web application

坚强是说给别人听的谎言 提交于 2019-12-11 04:51:36

问题


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:


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)



来源:https://stackoverflow.com/questions/1306462/how-to-manage-a-jmx-web-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!