question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Build Fails with NoClassDefFoundError on CglibMockMaker

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

16reactions
bric3commented, Apr 1, 2015

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

1reaction
europaJDMcommented, Sep 29, 2016

This trick saved my life

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.lang.NoClassDefFoundError: org/mockito/internal ...
I am getting this error log when I run the test through TestNG framework. java.lang.NoClassDefFoundError: org/mockito/internal/creation/CglibMockMaker at ...
Read more >
The java.lang.NoClassDefFoundError in JUnit - Baeldung
In this article, we'll understand why the java.lang.NoClassDefFoundError occurs in JUnit and how to fix it. This issue is mainly related to ...
Read more >
How to Resolve the NoClassDefFoundError in Java - Rollbar
NoClassDefFoundError is a Java error that occurs when the JVM is unable to find a class at runtime which was available at compile-time....
Read more >
3 ways to solve java.lang.NoClassDefFoundError in Java J2EE
NoClassDefFoundError is easier to solve than ClassNotFoundException in my opinion because here we know that Class was present at build time, but it...
Read more >
Java.Lang.Noclassdeffounderror: Org/Powermock/Core ...
When a build fails before all tests have run the test reports only include the ... NoClassDefFoundError: org/mockito/internal/creation/CglibMockMaker at ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found