javax / management / MBeanServer的加载程序约束冲突问题

时间:2017-08-30 08:58:28

标签: java jboss wildfly jmx

我正在尝试将应用程序从JBoss-4.0.4.GA迁移到wildfly-10.1.0.Final。我的JMX有问题。

在启动申请期间,我得到以下内容:

10:58:02,689 WARN  [org.jboss.modules] (ServerService Thread Pool -- 90) Failed to define class javax.management.MBeanServer in Module "com.xor.genesis:main" from local module loader @1c2c22f3 (finder: local module finder @18e8568 (roots: /home/user/wildfly-10.1.0.Final/modules,/home/user/wildfly-10.1.0.Final/modules/system/layers/base)): java.lang.LinkageError: Failed to link javax/management/MBeanServer (Module "com.xor.genesis:main" from local module loader @1c2c22f3 (finder: local module finder @18e8568 (roots: /home/chaos1/wildfly-10.1.0.Final/modules,/home/chaos1/wildfly-10.1.0.Final/modules/system/layers/base))): loader constraint violation: loader (instance of org/jboss/modules/ModuleClassLoader) previously initiated loading for a different type with name "javax/management/MBeanServer"
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
    at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
    at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:78)
    at org.jboss.modules.Module.loadModuleClass(Module.java:606)
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
    at com.xor.genesis.core.jmx.framework.ApplicationMBeanManager.registerMBean(ApplicationMBeanManager.java:37)
    at com.xor.genesis.cgo.listeners.CGOApplicationListener.registerApplicationLogger(CGOApplicationListener.java:161)
    at com.xor.genesis.cgo.listeners.CGOApplicationListener.initMBeans(CGOApplicationListener.java:112)
    at com.xor.genesis.cgo.listeners.CGOApplicationListener.contextInitialized(CGOApplicationListener.java:59)
    at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187)
    at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:200)
    at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:171)
    at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
    at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:234)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
    at org.jboss.threads.JBossThread.run(JBossThread.java:320)

为了在代码级别更精确,以下行产生上述异常:

MBeanServer server = java.lang.management.ManagementFactory.getPlatformMBeanServer();

我创建了自己的模块,其中包含所需的jar列表。我没有修改wildfly中的客户端库。

您对我如何处理此问题有任何想法吗?

谢谢, 阿纳托

1 个答案:

答案 0 :(得分:0)

这是错误消息的有趣部分:

  

加载器约束违规:loader(实例)   org / jboss / modules / ModuleClassLoader)先前已启动加载   一个名称不同的类型" javax / management / MBeanServer"在

更详细地解释了基本问题here。本文的结论是:

  

简单来说,如果有两个不同的类,就会发生链接错误   彼此交互,并且在这种交互中,类指的是   具有相同符号名称但具有不同类对象的类型。

不同的类对象源于类通过不同的类加载器加载的事实,因为每个类都由其FQN和(!)通过它加载的类加载器来标识。

请检查您的类路径中是否有多个javax / management / MBeanServer实例(在Wildfly / JBoss的modules目录中,甚至在部署中)。