`
kanpiaoxue
  • 浏览: 1781152 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

Java PowerMock Could not reconfigure JMX java.lang.LinkageError Solution

 
阅读更多
问题如下 
If you are using Mockito and PowerMock to build mocks for your Java tests and you run into the following error:

2016-05-05 17:31:20,204 main ERROR Could not reconfigure JMX 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:760)
at org.powermock.core.classloader.MockClassLoader.loadUnmockedClass(MockClassLoader.java:238)
at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:182)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:70)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

 

解决方案 
Simply add the following as a class level annotation:

@PowerMockIgnore( {"javax.management.*"})

 

参考地址: 

http://www.ryanchapin.com/fv-b-4-816/Java-PowerMock-Could-not-reconfigure-JMX-java-lang-LinkageError-Solution.html

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics