[Solved] IllegalStateException: Could not initialize plugin MockMaker

If you are working on Spring boot 2.x applications which automatically includes Mockito Core dependency and you are facing this error, then you may try the solution suggested.

1. Problem

Mockito core depends on a library called byte-buddy and this problem is mostly occurred when mocito doesn’t find a matching byte buddy jar version. Error looks like this:

java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker (alternate: null)
	at org.mockito.internal.configuration.plugins. PluginLoader$1.invoke(PluginLoader.java:74) ~[mockito-core-2.23.4.jar:na]
	at com.sun.proxy.$Proxy61.getHandler(Unknown Source) ~[na:na]
	at org.mockito.internal.util. MockUtil.isMock(MockUtil.java:81) ~[mockito-core-2.23.4.jar:na]
Caused by: java.lang.NoClassDefFoundError: net/bytebuddy/dynamic/loading/ ClassInjector$UsingReflection
	at org.mockito.internal.creation.bytebuddy. SubclassInjectionLoader.<init>(SubclassInjectionLoader.java:28) ~[mockito-core-2.23.4.jar:na]
	at org.mockito.internal.creation.bytebuddy. SubclassByteBuddyMockMaker.<init>(SubclassByteBuddyMockMaker.java:33) ~[mockito-core-2.23.4.jar:na]
	at org.mockito.internal.creation.bytebuddy. ByteBuddyMockMaker.<init>(ByteBuddyMockMaker.java:21) ~[mockito-core-2.23.4.jar:na]
	... 19 common frames omitted
Caused by: java.lang.ClassNotFoundException: net.bytebuddy.dynamic. loading.ClassInjector$UsingReflection
	at java.net.URLClassLoader.findClass(Unknown Source) ~[na:1.8.0_171]
	at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_171]
	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) ~[na:1.8.0_171]
	at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_171]
	... 42 common frames omitted

2. Solution

  • Find out the mockito core version your project is using. In eclipse, you can check in project build path by navigating to

    Right click on project -> Properties -> Java build path -> Libraries tab

    Mockito core dependency
    Mockito core dependency
  • Search maven repository for that version of mockito core. To me, it was : https://mvnrepository.com/artifact/org.mockito/mockito-core/2.23.4
  • Look at the Compile Dependencies section. Note down the correct dependent version of byte-buddy and include in the project. If the jar is already included with some other version, override the version with this correct version.

    Correct jar version
    Correct jar version

Build the application and run the tests again. Your issue related to MockMaker must be solved by now.

Happy Learning !!

Was this post helpful?

Join 7000+ Awesome Developers

Get the latest updates from industry, awesome resources, blog updates and much more.

* We do not spam !!

3 thoughts on “[Solved] IllegalStateException: Could not initialize plugin MockMaker”

  1. In my case it was an even weirder problem. Somehow, don’t really know why, the directory where IntelliJ was looking for the JDK got changed somewhere along the way. Result was that, overnight, all tests stopped working while throwing this exact same error.
    After struggling with it for a day I finally came up with the solution which was going to File->Project Structure->SDKs, there I chose the JDK the project was set to (Java 11 in my case), and found out it was pointing to a whole different place, I just redirected it to the folder where my JDK was and everything went back to normal.
    Hope it helps!


Leave a Comment


A blog about Java and related technologies, the best practices, algorithms, and interview questions.