Mockito: Build Fails with NoClassDefFoundError on CglibMockMaker

Created on 1 Apr 2015  路  6Comments  路  Source: mockito/mockito

Hi,
my maven build fails when I try to mock a class with the error below. I am beginner with mockito. Can someone please help with this? I am trying to build from command line. I am trying to build a scala project.

Java version: 1.7
Project type: scala project
mockito version:

<dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-all</artifactId>
    <version>1.10.19</version>
</dependency>

Error that I get during maven build:

鈫怺31m*** RUN ABORTED ***鈫怺0m
鈫怺31m  java.lang.NoClassDefFoundError: org/mockito/internal/creation/CglibMockMaker鈫怺0m
鈫怺31m  at org.powermock.api.mockito.internal.mockmaker.PowerMockMaker.<init>(PowerMockMaker.java:40)鈫怺0m
鈫怺31m  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)鈫怺0m
鈫怺31m  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)鈫怺0m
鈫怺31m  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)鈫怺0m
鈫怺31m  at java.lang.reflect.Constructor.newInstance(Constructor.java:526)鈫怺0m
鈫怺31m  at java.lang.Class.newInstance(Class.java:374)鈫怺0m
鈫怺31m  at org.mockito.internal.configuration.plugins.PluginLoader.loadImpl(PluginLoader.java:61)鈫怺0m
鈫怺31m  at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:24)鈫怺0m
鈫怺31m  at org.mockito.internal.configuration.plugins.PluginRegistry.<init>(PluginRegistry.java:12)鈫怺0m
鈫怺31m  at org.mockito.internal.configuration.plugins.Plugins.<clinit>(Plugins.java:11)鈫怺0m
鈫怺31m  ...鈫怺0m
鈫怺31m  Cause: java.lang.ClassNotFoundException: org.mockito.internal.creation.CglibMockMaker鈫怺0m
鈫怺31m  at java.net.URLClassLoader$1.run(URLClassLoader.java:366)鈫怺0m
鈫怺31m  at java.net.URLClassLoader$1.run(URLClassLoader.java:355)鈫怺0m
鈫怺31m  at java.security.AccessController.doPrivileged(Native Method)鈫怺0m
鈫怺31m  at java.net.URLClassLoader.findClass(URLClassLoader.java:354)鈫怺0m
鈫怺31m  at java.lang.ClassLoader.loadClass(ClassLoader.java:425)鈫怺0m
鈫怺31m  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)鈫怺0m
鈫怺31m  at java.lang.ClassLoader.loadClass(ClassLoader.java:358)鈫怺0m
鈫怺31m  at org.powermock.api.mockito.internal.mockmaker.PowerMockMaker.<init>(PowerMockMaker.java:40)鈫怺0m
鈫怺31m  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)鈫怺0m
鈫怺31m  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)鈫怺0m
鈫怺31m  ...鈫怺0m

Most helpful comment

Oh I just identified the issue, this project is using powermock, which is depending / hacking in mockito internals, those have change in version 1.10.8. However there's a new version of powermock 1.6.2 that work with mockito 1.10.19

All 6 comments

Hi,

We are happy that you are using mockito, but for support please use the mockito mailing-list or stackoverflow :)

With the given info there's not enough info to diagnose the issue, it seems to be related to classpath though.

Oh I just identified the issue, this project is using powermock, which is depending / hacking in mockito internals, those have change in version 1.10.8. However there's a new version of powermock 1.6.2 that work with mockito 1.10.19

Thanks...It did the trick and saved my time!! :)

This trick saved my life

You saved the day bro!
Thanks. :)

Thanks a lot bric3 :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Raghu290 picture Raghu290  路  4Comments

d1231 picture d1231  路  5Comments

TimvdLippe picture TimvdLippe  路  5Comments

fbourbonnais picture fbourbonnais  路  4Comments

bharukaRupesh picture bharukaRupesh  路  3Comments