• Bug
  • Status: Closed
  • 2 Major
  • Resolution: Fixed
  • hhuynh
  • Reporter: teck
  • May 08, 2007
  • 0
  • Watchers: 0
  • September 24, 2007
  • June 13, 2007

Description

From the forums: http://forums.terracotta.org/forums/posts/list/235.page

We might need to rethink the conditions in which we are the one creating the first mbean server. At the very least, something that gives a user a means to control this aspect a little more could go a long way

Comments

Nathaniel Harward 2007-05-09

The forum poster describes the “normal” way to get the MBean server using ManagementFactory.getPlatformMBeanServer(); unfortunately this is 1.5+ and we have to support 1.4 – the method currently used is 1.4+ compatible. I see our options as twofold: 1) make a parallel code module that is discovered at runtime to use either the old 1.4 way if on 1.4 and the “normal” way if on 1.5 or 2) look at the JDK source and see what ManagementFactory.getPlatformMBeanServer() does under the covers, and see if we can’t re-work our code to operate nicely within that framework while still being 1.4 compatible (this is preferred IMHO, I don’t like the annoyance of parallel 1.4/1.5 modules).

I’m still not exactly sure why this is a problem: it seems to me that if we are doing the same thing as Tomcat (though there is a potential race condition there) then whoever got there first would win, and the second-in would just use the MBean server that the other created. My guess is that the “platform” MBeanServer must somehow be created differently, or this race condition is just hitting and two MBean servers are getting created by us first and then Tomcat.

I think we should look at the ManagementFactory.getPlatformMBeanServer() code and see what’s going on.

Tim Eck 2007-05-10

I thought under 1.4 our JMX world is completely scoped within our loader (if the mbean server is coming from jars in our lib directory, then I’m really certain this is the case) – if so, I wouldn’t think there is anything to worry about then (for 1.4), no? Which leaves 1.5 of course – Personally I think code that makes assumptions about the order of servers in that static factory could use work, but we might just have to workaround it

Nathaniel Harward 2007-06-12

As predicted: ManagementFactory has a static MBeanServer field that it uses internally, and to initialize it it always creates a new MBeanServer, so for 1.5+ we just have to wait for it.