Arghhhhh! This error happened again! I’m feeling weird on this error as I never invoke any
MBeanServer thing in my code. And this error sound familiar to me, I think I have seen the similar error happened before, but I couldn’t recall my memory. I wasn't sure whether this is a common defect only happened on
Powermock 1.6 but it is quite annoying me.
Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of org/powermock/core/classloader/MockClassLoader) previously initiated loading for a different type with name "javax/management/MBeanServer"
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
at org.powermock.core.classloader.MockClassLoader.loadUnmockedClass(MockClassLoader.java:237)
at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:182)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:68)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.apache.logging.log4j.core.jmx.Server.unregisterAllMatching(Server.java:307)
at org.apache.logging.log4j.core.jmx.Server.unregisterLoggerContext(Server.java:229)
at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:140)
at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:119)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:356)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:386)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:149)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:84)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:35)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:444)
at com.awpl.worker.AbstractWorker.<init>(AbstractWorker.java:60)
at com.awpl.worker.WorkerWithTriggerFile.<init>(WorkerWithTriggerFile.java:22)
at com.awpl.worker.WorkerWithTriggerFileTest.throwFileNotFoundException(WorkerWithTriggerFileTest.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606) at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:68)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:310)
... 23 more
So what I did is just ignore this particular error and my unit test is proceed as usual:
@PowerMockIgnore({"javax.management.*"})
public class TheClassTest {
…
}
No comments:
Post a Comment