简体   繁体   English

如何管理JMX Web应用程序

[英]How to manage a JMX web application

I've gone through the process on this page to expose the JMX interface of a web application. 我已经完成了页面上的过程,以暴露Web应用程序的JMX界面。

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. 我设法查看了Tomcat JMX代理上的公开接口,但是当我加载JConsole并查找公开的mbean接口时,我找不到与公开的属性和操作相关的任何内容。

Thre is no specific entry on jconsole for the web app so I figured it might be under the TOMCAT jmx entry. 在Web应用程序的jconsole上没有特定的条目,因此我认为它可能在TOMCAT jmx条目下。 It's not. 不是。 (bare in mind, I did manage to see it on the tomcat jmx proxy page). (请记住,我确实在tomcat jmx代理页面上看到了它)。

How can I manage my web application locally? 如何在本地管理我的Web应用程序? Why is JConsole not showing it? JConsole为什么不显示它?

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). 在webapp上下文侦听器contextInitialized方法中,我实例化了一个将运行并实现mbean的单例类(servlet本身无法实现mbean,因为它仅醒来以接受来自服务器的请求)。
  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. servlet“通知”我们要监视的每个操作的单例,而单例实际上是通过jmx报告此操作的单例。
  3. In the singleton I registered with the mbean server with this command: 在单例中,我使用以下命令在mbean服务器上注册:

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

Thats it. 而已。 (In a nut shell) (简而言之)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM