Я перенес проект с Tomcat 7 на 8 и у меня возникла необычная проблема: если ничего не изменилось в конфиге, я обнаружил ошибку:
javax.management.InstanceAlreadyExistsException: com.sgs.tools.mri.jmx:type=MRIMonitor
at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324)
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
at com.sgs.tools.mri.MRIProfiler.<init>(MRIProfiler.java:94)
at com.sgs.tools.mri.MRIProfiler.<clinit>(MRIProfiler.java:40)
at com.sgs.tools.mri.aspects.MRIAspect.<clinit>(MRIAspect.java:38)
at com.matrixone.apps.domain.util.ContextUtil.pushContext(ContextUtil.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.dassault_systemes.i3dx.util.ContextUtil.pushContext(ContextUtil.java:54)
at com.dassault_systemes.i3dx.monitoring.daemon.MonitoringDaemon.intializeContext(MonitoringDaemon.java:44)
at com.dassault_systemes.i3dx.monitoring.daemon.MonitoringDaemon.<init>(MonitoringDaemon.java:33)
at com.dassault_systemes.i3dx.monitoring.daemon.MonitoringDaemonManager.contextInitialized(MonitoringDaemonManager.java:28)
private MRIProfiler(){
// register Management Bean enabling control via
Class<?> classVar = MRIProfiler.class;
System.out.println("Current Class Loader ================== : "+ classVar.getClassLoader().getClass().getName());
try {
MBeanServer mbn = ManagementFactory.getPlatformMBeanServer();
ObjectName name = new ObjectName("com.sgs.tools.mri.jmx:type=MRIMonitor");
MRIMonitor mbean=new MRIMonitor();
mbn.registerMBean(mbean, name);
System.out.println("Registered()......!");
} catch (JMException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
};
}
Я хочу успешно bean Зарегистрирован