nickylin / powermock

Automatically exported from code.google.com/p/powermock
Apache License 2.0
0 stars 0 forks source link

Incompatibility with mockito 1.10.9 and 1.10.10 #524

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I used mockito 1.10.8 with powermock-api-mockito:1.5.6, and it worked fine.

I tried upgrading to mockito 1.10.9 and 1.10.10, but I got:

java.lang.IllegalAccessError: org/mockito/internal/creation/cglib/CGLIBHacker
        at org.mockito.internal.creation.MethodInterceptorFilter.<init>(MethodInterceptorFilter.java:27)
        at org.powermock.api.mockito.internal.mockcreation.PowerMockMethodInterceptorFilter.<init>(PowerMockMethodInterceptorFilter.java:18)
        at org.powermock.api.mockito.internal.mockcreation.MockCreator.createMethodInvocationControl(MockCreator.java:109)
        at org.powermock.api.mockito.internal.mockcreation.MockCreator.mock(MockCreator.java:60)
        at org.powermock.api.mockito.PowerMockito.mock(PowerMockito.java:143)

and also

java.lang.NoClassDefFoundError: Could not initialize class 
org.mockito.internal.creation.jmock.ClassImposterizer
        at org.mockito.internal.creation.CglibMockMaker.createMock(CglibMockMaker.java:23)
        at org.powermock.api.mockito.internal.mockmaker.PowerMockMaker.createMock(PowerMockMaker.java:43)
        at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:32)
        at org.mockito.internal.MockitoCore.mock(MockitoCore.java:59)
        at org.mockito.Mockito.mock(Mockito.java:1258)

I assume you don't need an example to reproduce, any existing unit tests 
probably break as well.

Original issue reported on code.google.com by tibokr...@googlemail.com on 30 Oct 2014 at 4:05

GoogleCodeExporter commented 9 years ago
1.10.9 or 1.10.10 are no longer available in Central, so I jumped from 1.10.8 
to 1.10.16 or 1.10.17 and have the following problem. powermock-api-mockito 
1.6.0, junit 4.11.

java.lang.NoClassDefFoundError: org/mockito/internal/creation/CglibMockMaker
    at org.powermock.api.mockito.internal.mockmaker.PowerMockMaker.<init>(PowerMockMaker.java:40)
    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:408)
    at java.lang.Class.newInstance(Class.java:438)
    at org.mockito.internal.configuration.plugins.PluginLoader.loadImpl(PluginLoader.java:61)
    at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:24)
    at org.mockito.internal.configuration.plugins.PluginRegistry.<init>(PluginRegistry.java:12)
    at org.mockito.internal.configuration.plugins.Plugins.<clinit>(Plugins.java:11)
    at org.mockito.internal.util.MockUtil.<clinit>(MockUtil.java:24)
    at org.mockito.internal.configuration.injection.scanner.MockScanner.<init>(MockScanner.java:22)
    at org.mockito.internal.configuration.InjectingAnnotationEngine.injectMocks(InjectingAnnotationEngine.java:96)
    at org.powermock.api.mockito.internal.configuration.PowerMockitoInjectingAnnotationEngine.process(PowerMockitoInjectingAnnotationEngine.java:35)
    at org.powermock.api.extension.listener.AnnotationEnabler.injectSpiesAndInjectToSetters(AnnotationEnabler.java:60)
    at org.powermock.api.extension.listener.AnnotationEnabler.beforeTestMethod(AnnotationEnabler.java:55)
    at org.powermock.tests.utils.impl.PowerMockTestNotifierImpl.notifyBeforeTestMethod(PowerMockTestNotifierImpl.java:90)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:292)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:127)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:82)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:282)
    at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:86)
    at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:207)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:146)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:120)
    at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:33)
    at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:45)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:122)
    at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:106)
    at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
    at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:59)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.lang.ClassNotFoundException: 
org.mockito.internal.creation.CglibMockMaker
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:178)
    at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:68)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 44 more
Caused by: java.lang.ClassNotFoundException: 
org.mockito.internal.creation.CglibMockMaker
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:178)
    at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:68)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 44 more

Original comment by lobsterl...@gmail.com on 22 Dec 2014 at 6:11

GoogleCodeExporter commented 9 years ago
any news on this issue? just upgraded from mockito 1.9.5 to 1.10.19 and 
powermock 1.5 to 1.6.1 (for junit 4.12) and getting the same error:

java.lang.NoClassDefFoundError: org/mockito/internal/creation/CglibMockMaker
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at org.powermock.api.mockito.internal.mockmaker.PowerMockMaker.<init>(PowerMockMaker.java:40)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at java.lang.Class.newInstance(Class.java:379)
    at org.mockito.internal.configuration.plugins.PluginLoader.loadImpl(PluginLoader.java:61)
    at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:24)
    at org.mockito.internal.configuration.plugins.PluginRegistry.<init>(PluginRegistry.java:12)
    at org.mockito.internal.configuration.plugins.Plugins.<clinit>(Plugins.java:11)
    at org.mockito.internal.util.MockUtil.<clinit>(MockUtil.java:24)
    at org.mockito.internal.stubbing.defaultanswers.ReturnsEmptyValues.<init>(ReturnsEmptyValues.java:58)
    at org.mockito.internal.stubbing.defaultanswers.ReturnsMoreEmptyValues.<init>(ReturnsMoreEmptyValues.java:51)
    at org.mockito.internal.stubbing.defaultanswers.ReturnsSmartNulls.<init>(ReturnsSmartNulls.java:40)
    at org.mockito.Answers.<clinit>(Answers.java:43)
    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 java.lang.Class.getEnumConstantsShared(Class.java:3128)
    at java.lang.Class.enumConstantDirectory(Class.java:3149)
    at java.lang.Enum.valueOf(Enum.java:231)
    at sun.reflect.annotation.AnnotationParser.parseEnumValue(AnnotationParser.java:475)
    at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:340)
    at java.lang.reflect.Method.getDefaultValue(Method.java:741)
    at sun.reflect.annotation.AnnotationType.<init>(AnnotationType.java:128)
    at sun.reflect.annotation.AnnotationType.getInstance(AnnotationType.java:85)
    at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:263)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:117)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:70)
    at java.lang.reflect.Field.declaredAnnotations(Field.java:1128)
    at java.lang.reflect.Field.getDeclaredAnnotations(Field.java:1121)
    at java.lang.reflect.AccessibleObject.getAnnotations(AccessibleObject.java:196)
    at org.junit.runners.model.FrameworkField.getAnnotations(FrameworkField.java:31)
    at org.junit.runners.model.TestClass.addToAnnotationLists(TestClass.java:84)
    at org.junit.runners.model.TestClass.scanAnnotatedMembers(TestClass.java:71)
    at org.junit.runners.model.TestClass.<init>(TestClass.java:57)
    at org.junit.runners.ParentRunner.createTestClass(ParentRunner.java:88)
    at org.junit.runners.ParentRunner.<init>(ParentRunner.java:83)
    at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:65)
    at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl$1.<init>(JUnit45AndHigherRunnerImpl.java:23)
    at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.<init>(JUnit45AndHigherRunnerImpl.java:23)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.mockito.internal.runners.util.RunnerProvider.newInstance(RunnerProvider.java:39)
    at org.mockito.internal.runners.RunnerFactory.create(RunnerFactory.java:28)
    at org.mockito.runners.MockitoJUnitRunner.<init>(MockitoJUnitRunner.java:57)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:262)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
    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.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:208)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:158)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:86)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:95)

Original comment by michael....@gmail.com on 5 Jan 2015 at 11:58

GoogleCodeExporter commented 9 years ago
I have the same issue. Compatibility with all Versions of Mockito >=1.10.9 
seems to be broken.

Original comment by michael....@gmail.com on 8 Jan 2015 at 12:05

GoogleCodeExporter commented 9 years ago
Same thing here. The last mockito version that properly works with powermock is 
1.10.8.

Original comment by marcos.p...@edulify.com on 13 Jan 2015 at 6:28

GoogleCodeExporter commented 9 years ago
Hi,

Putting mockito-core into the pom.xml solved for me.
Mockito core uses different CGLib version or something like that.
So put mockito-core before powermock and see the result.
It is good for temporary workaround.

Original comment by bokor.an...@gmail.com on 27 Jan 2015 at 10:44

GoogleCodeExporter commented 9 years ago
I use mockito-core in my projects, but I experienced this problem, too. What 
version of mockito-core are you using?

Original comment by jrh...@gmail.com on 27 Jan 2015 at 2:19

GoogleCodeExporter commented 9 years ago
Nothing to do with upgraded CGLIB. The thing is that mockito changed / cleaned 
some of it's internal. In order to better isolate CGLIB stuff, that includes 
renaming, changing packages, using package visibility, etc.

PowerMock rely on a lot of mockito internals, with recent refactoring on 
Mockito side I have the feeling that PowerMock will have to repackage mockito, 
at least the classes that powermock uses.

Original comment by brice.du...@gmail.com on 29 Jan 2015 at 10:53

GoogleCodeExporter commented 9 years ago
Brice has submitted a pull request that includes some of the Mocktio internals. 
I accept it for now as a workaround but a better solution is probably required 
otherwise PowerMock will move away from original Mockito too much.

Original comment by johan.ha...@gmail.com on 30 Jan 2015 at 8:32

GoogleCodeExporter commented 9 years ago
I'm confused this tickets state was set to "Fixed". I still have to use 
mockito-1.10.8. Any official progress on this?

Original comment by konrad.j...@acrolinx.com on 20 Feb 2015 at 3:34

GoogleCodeExporter commented 9 years ago
Hi, I am facing the same issue. Just voicing out again, I don't think the 
workaround is right. Any comments on reopening this issue

Original comment by chunkia...@gmail.com on 25 Feb 2015 at 8:31

GoogleCodeExporter commented 9 years ago
I face similar issues, adding mockito-core to POM doesn't help either.

Original comment by babbupan...@gmail.com on 27 Feb 2015 at 1:54

GoogleCodeExporter commented 9 years ago
I experience the same issue. Any news on this ?

Original comment by pascal.g...@gmail.com on 27 Feb 2015 at 4:46

GoogleCodeExporter commented 9 years ago
This issue is still not fixed. Who is responsible to correct the status from 
fixed to open?

Original comment by marcus.f...@gmail.com on 16 Mar 2015 at 11:57

GoogleCodeExporter commented 9 years ago
Apparently, with powermock 1.6.2, you need to use a version of mockito more 
recent than 1.10.8. It seems OK with mockito 1.10.19 for instance.

Original comment by lrichard...@gmail.com on 16 Mar 2015 at 2:45

GoogleCodeExporter commented 9 years ago
powermock 1.6.2 with mockito 1.10.19 works for me, too.
As a side-note, 1.6.2 does not appear here: 
http://mvnrepository.com/artifact/org.powermock

Original comment by tibokr...@googlemail.com on 16 Mar 2015 at 4:39

GoogleCodeExporter commented 9 years ago
> As a side-note, 1.6.2 does not appear here: 
http://mvnrepository.com/artifact/org.powermock

May have just taken it a bit for it to catch up. I see 1.6.2 now.

Original comment by jrh...@gmail.com on 26 Mar 2015 at 3:31

GoogleCodeExporter commented 9 years ago
Will this be fixed with 2.0, or do we still have to use the 
mockito-core/PowerMock workarounds? I really need the Mockito rule, but I can't 
upgrade PowerMock due to EasyMock dependencies.

Original comment by orbf...@gmail.com on 29 Mar 2015 at 9:09