Welcome to my website. I am always posting links to photo albums, art, technology and other creations. Everything that you will see on my numerous personal sites is powered by the formVistaTM Website Management Engine.

icon.linkedin.jpgicon.twitter.jpg

  • Java PowerMock Could not reconfigure JMX java.lang.LinkageError Solution
    08/09/2016 9:00AM

    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.*"})

Advanced Search

Categories

Archives