try {
server = MBeanServerFactory.createMBeanServer(JMX_DOMAIN);
// thats right. There is no common base class for the
// exceptions this throws so catch them all.
} catch (SecurityException se) {
throw new PageTrackerException("You do not have permission to" +
"create an MBeanServer", se);
} catch (JMRuntimeException jre) {
throw new PageTrackerException("Could not create MBeanServer. " +
"This can occur for two reasons.\n1) the property " +
"\"javax.management.builder.initial\" is set but " +
"the specified class cannot be instanciated.\n2) " +
"The instanciated class is returning null from " +
"calls to its \"newMBeanServerDelegate\" or" +
"\"newMBeanServer\" method.", jre);
} catch (ClassCastException cce) {
throw new PageTrackerException("The class specified in " +
"\"javax.management.builder.initial\" is" +
"not assignment compatible with MBeanServerBuilder",
cce);
}
} else {
// if our MBeanServer is not registered then throw an exception
// as someone else has deregistered it.
if (!isMBeanServerRegistered(server)) {
String errorMessage = "The Volantis MBeanServer does not " +
"appear to be registered with the factory. It is " +
"likely that someone else has deregistered it.";
throw new PageTrackerException(errorMessage);
}
}
registerBeanWithServer();
}