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.

[W7/Java8] Could not initialize plugin: interface org.mockito.plugins.MockMaker

See original GitHub issue

I’ve seen this issue occur in other Issues posted here as well as on StackOverflow, but mine seems particularly weird and none of the other posts’ resolutions have worked for me.

My current project at work has ~80 tests that use Mockito 2.18.3 + Scalatest 3.0.5 together, including the mock-maker-inline config to be able to use the new engine and mock/spy on final classes.

All of the tests run just fine using IntelliJ Idea’s test runner/debugger. When I (locally) run the mvn test lifecycle, since this is what happens in our deployment, all of the tests that use the final class mock fail with the stack below.

I’m importing Mockito in my pom.xml as follows

<dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-core</artifactId>
    <version>2.18.3</version>
</dependency>

Getting the trace below. Any tips would be appreciated.

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)
  at com.sun.proxy.$Proxy26.isTypeMockable(Unknown Source)
  at org.mockito.internal.util.MockUtil.typeMockabilityOf(MockUtil.java:29)
  at org.mockito.internal.util.MockCreationValidator.validateType(MockCreationValidator.java:22)
  at org.mockito.internal.creation.MockSettingsImpl.validatedSettings(MockSettingsImpl.java:232)
  at org.mockito.internal.creation.MockSettingsImpl.build(MockSettingsImpl.java:226)
  at org.mockito.internal.MockitoCore.mock(MockitoCore.java:64)
  at org.mockito.Mockito.mock(Mockito.java:1875)
  at org.mockito.Mockito.mock(Mockito.java:1784)
  at org.scalatest.mockito.MockitoSugar$class.mock(MockitoSugar.scala:73)
  ...
  Cause: java.lang.IllegalStateException: Failed to load interface org.mockito.plugins.MockMaker implementation declared in sun.misc.CompoundEnumeration@2bebb74f
  at org.mockito.internal.configuration.plugins.PluginInitializer.loadImpl(PluginInitializer.java:54)
  at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:57)
  at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:44)
  at org.mockito.internal.configuration.plugins.PluginRegistry.<init>(PluginRegistry.java:21)
  at org.mockito.internal.configuration.plugins.Plugins.<clinit>(Plugins.java:18)
  at org.mockito.internal.util.MockUtil.<clinit>(MockUtil.java:24)
  at org.mockito.internal.util.MockCreationValidator.validateType(MockCreationValidator.java:22)
  at org.mockito.internal.creation.MockSettingsImpl.validatedSettings(MockSettingsImpl.java:232)
  at org.mockito.internal.creation.MockSettingsImpl.build(MockSettingsImpl.java:226)
  at org.mockito.internal.MockitoCore.mock(MockitoCore.java:64)
  ...
  Cause: org.mockito.exceptions.base.MockitoInitializationException: Could not initialize inline Byte Buddy mock maker. (This mock maker is not supported on Android.)

Java               : 1.8
JVM vendor name    : Oracle Corporation
JVM vendor version : 25.161-b12
JVM name           : Java HotSpot(TM) 64-Bit Server VM
JVM version        : 1.8.0_161-b12
JVM info           : mixed mode
OS name            : Windows 7
OS version         : 6.1
  at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.<init>(InlineByteBuddyMockMaker.java:171)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
  at java.lang.reflect.Constructor.newInstance(Unknown Source)
  at java.lang.Class.newInstance(Unknown Source)
  at org.mockito.internal.configuration.plugins.PluginInitializer.loadImpl(PluginInitializer.java:49)
  at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:57)
  at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:44)
  at org.mockito.internal.configuration.plugins.PluginRegistry.<init>(PluginRegistry.java:21)
  ...
  Cause: java.lang.IllegalStateException: No compatible attachment provider is available
  at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:366)
  at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:351)
  at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:319)
  at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:305)
  at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.<clinit>(InlineByteBuddyMockMaker.java:101)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
  at java.lang.reflect.Constructor.newInstance(Unknown Source)
  at java.lang.Class.newInstance(Unknown Source)
  ...

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:16
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
hmedatcommented, Sep 25, 2018

Any updates?

0reactions
cuneytykayacommented, Aug 2, 2021

Hi @rcornell Any update on this issue? Did you find a solution? I get the same error when I use jmockit and mockito-inline together in a project.

Thanks in advance.

Read more comments on GitHub >

github_iconTop Results From Across the Web

interface org.mockito.plugins.MockMaker - Stack Overflow
With this dependency I always get an error like: java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker ( ...
Read more >
interface org.mockito.plugins.MockMaker · Issue #2627 - GitHub
Occurs with 4.5.0 and above, does not occur with 4.4.0 Similar to #2625, ... Could not initialize plugin: interface org.mockito.plugins.
Read more >
Could not initialize plugin MockMaker - HowToDoInJava
The root cause of this error is the version mismatch between Mockito and ByteBuddy. For a few people, it turned out to be...
Read more >
IllegalStateException: Could not initialize plugin MockMaker
Mockito core depends on a library called byte-buddy and this problem is ... IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.
Read more >
Could not initialize inline Byte Buddy mock maker. (This mock ...
IllegalStateException : Could not initialize plugin: interface org.mockito.plugins.MockMaker (alternate: null) at controllers.MockModules.getItemStore(
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