[jboss-user] [Management, JMX/JBoss] - MBeanServer.getDefaultDomain returns null

vrsn-rbuck do-not-reply at jboss.com
Wed Jul 23 09:53:25 EDT 2008


When JBoss is run with these additional options, to expose JBoss MBean's in JConsole, application code that looks up the MBeanServer gets an NPE.

When one starts JBoss with the following options:

set JAVA_OPTS=%JAVA_OPTS% -Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl
  | set JAVA_OPTS=%JAVA_OPTS% -Djboss.platform.mbeanserver
  | set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote
  | 

which is detailed here on your site:

http://wiki.jboss.org/wiki/JBossMBeansInJConsole

Calls to server.getDefaultDomain() returns null when should not have. Here is my applications JMX helper:

    public static MBeanServer getDefaultMBeanServer() {
  |         // detects if we are running from within jboss...
  |         MBeanServer server = findMBeanServer("jboss");
  | 
  |         // otherwise falls back to the default platform mbean server...
  |         if (server == null) {
  |             server = ManagementFactory.getPlatformMBeanServer();
  |         }
  |         return server;
  |     }
  | 
  |     private static MBeanServer findMBeanServer(String agentId) {
  |         List servers = MBeanServerFactory.findMBeanServer(null);
  |         if (servers != null && servers.size() > 0) {
  |             for (Object object : servers) {
  |                 MBeanServer server = (MBeanServer) object;
  |                 if (server.getDefaultDomain().equals(agentId)) {
  |                     return server;
  |                 }
  |             }
  |         }
  |         return null;
  |     }
  | 

There was a related thread that never got an answer back in 2007:

http://lists.jboss.org/pipermail/jboss-user/2007-February/038880.html

This looks like a defect in JBoss. If so, what workaround exists for it?


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4166145#4166145

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4166145



More information about the jboss-user mailing list