in hawtio-local-jvm-mbean/src/main/java/io/hawt/jvm/local/JVMList.java [77:112]
public void init() {
LOG.debug("Registering JVM discovery MBean: hawtio:type=JVMList");
try {
try {
// let's just hit any errors we're going to hit before even creating the mbean
listLocalJVMs();
} catch (LinkageError e) {
// Some JVM's don't support com.sun.tools.attach.VirtualMachine
LOG.warn(
"Local JVM discovery disabled as this JVM cannot access com.sun.tools.attach.VirtualMachine due to: {}",
e.getMessage());
return;
}
if (objectName == null) {
objectName = new ObjectName("hawtio:type=JVMList");
}
if (mBeanServer == null) {
mBeanServer = ManagementFactory.getPlatformMBeanServer();
}
try {
mBeanServer.registerMBean(this, objectName);
} catch (InstanceAlreadyExistsException iaee) {
// Try to remove and re-register
LOG.info("Re-registering SchemaLookup MBean");
mBeanServer.unregisterMBean(objectName);
mBeanServer.registerMBean(this, objectName);
}
} catch (Exception e) {
LOG.warn("Exception during initialization: ", e);
throw new RuntimeException(e);
}
LOG.info("Registered JVM discovery MBean: hawtio:type=JVMList");
}