Im upgrading log4j from 1.x to 2.3. after setting up maven dependencies my project is builing and application is running fine.
But while builing, at test goal getting below mentioned error in variouse unit Test classes which are already there.
I could find a workaround by using @PowerMockIgnore. But worried of changing all the 100s of files which are already written.
ERROR StatusLogger Could not reconfigure JMX java.lang.LinkageError: loading constraint violation: loader "org/powermock/core/classloader/MockClassLoader@5fa95fa9" previously initiated loading for a different type with name "javax/management/MBeanServer" defined by loader "com/ibm/oti/vm/BootstrapClassLoader@7a5c7a5c".
@see Mockito + PowerMock LinkageError while mocking system class
Try adding this annotation to your Test class:
@PowerMockIgnore("javax.management.*")
Worked for me.
And worked for me as well
If you have many test classes and using powermock from version 1.7.0 you can specify a global config. See power mock configuration it comes with an example project where its use is demonstrated see example.
The configuration file should have:
powermock.global-ignore=javax.management.*
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With