Kristian Glass - Do I Smell Burning?

MBeans and naming collisions

I currently spend some time with a setup where every application has its own embedded Jetty listening on its own port with its own magically-generated properties files for resource configuration. At the moment I’m leading the migration to replace this with a per-machine servlet container (probably Apache Tomcat) with JNDI support. This way we have just one port number to remember, one JMX URL to point JConsole at, far more centralised configuration, and a greater separation of “application” from “system”.

One issue that came up when centralising the JMX setup, and having everything register with the One True MBeanServer, rather than there being one for each application, was handling overlapping MBeans.

Fortunately, it turns out that the people over at Xebia France have some nice public “JMX-based extras to ease monitoring”. In there is the rather nifty “Servlet Context Aware MBean Server” (licensed under the pretty user-friendly Apache License 2.0) which solves this problem beautifully by adding a “path” attribute to each MBean matching the context path of the app.

So, since no two applications in the same servlet container (and thus sharing the MBeanServer) will have the same context path, we achieve MBean naming uniqueness!

They even include the necessary chunk of Spring XML, meaning it took me seconds to try out. All in all, a nice and concise solution that is absolutely trivial to get up and running - thanks guys!