users@glassfish.java.net

JMX in servlets

From: Christopher Piggott <cpiggott_at_gmail.com>
Date: Sun, 24 Jun 2012 22:07:23 -0400

Hi,

I wrote a Jersey application running in a servlet container. When I
first did this I hosted it in an embedded server (specifically
grizzly). I added some MXBeans to it, registered using:

        ObjectName o = new ObjectName(name);
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        mbs.registerMBean(profiler, o);

I'm now in the process of moving it into glassfish, and I'm wondering
... is this still the right way to get the MBeanServer, or should I be
getting it through some server context (e.g. jndi). I want to do
what's "safe" ... if something goes wonky in my servlet, I don't want
it to screw up the rest of the MBeanServer as used by Glassfish
itself.

--Chris