tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Neven Cvetkovic <>
Subject Re: Monitoring multiple tomcat instances from single app
Date Wed, 10 Apr 2013 02:17:28 GMT

Here's an example application that has a CounterServlet that counts hits
for example... Here are the classes that I used

- CounterServlet - just counts number of hits, calls
MyCounter.incrementAndGet() static method
- MyCounter - class that implements the counter (static calls to reset
counter, get current count, etc...)

- CounterMBean - interface for the MBean I am registering ... all methods
getXxxxxx() will get translated into attribute "xxxxx", all methods
setXxxxxx() will translate into writable attribute "xxxxxx"
- Counter - implements CounterMBean interface (naming is important here
Counter class and CounterMBean interface ... i.e. Xxxx class and XxxxMBean

- RegisterMBeansListener - @WebListener that implements
ServletContextListener and registers/unregisters the mbean upon

That's it....

I will attach the WAR file, so you can just deploy it and call the MBean
from jconsole/jvisualvm. I registered:

JmxExample:type=Counter  ... operations are resetCounter() and
resetCounter(int), attributes are currentTimeMilis, currentTime,

If the WAR didn't make it to the mailing list, contact me directly and I
will attach it.

Have fun with JMX :))

View raw message