mockito: AttachNotSupportedException: no providers installed. When using mock-maker-inline extension and jmockit.jar is found in classpath on Windows.
Hello. We have mixed environment where some test are written with help of mockito with mock-maker-inline extension and some test use jmockit.
When test are running under OS X everything works fine. But under Windows we have following exception:
Caused by: java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker
at org.mockito.internal.configuration.plugins.PluginLoader$1.invoke(PluginLoader.java:66)
at com.sun.proxy.$Proxy48.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:168)
at org.mockito.internal.creation.MockSettingsImpl.confirm(MockSettingsImpl.java:162)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:64)
at org.mockito.Mockito.spy(Mockito.java:1788)
at org.kubek2k.springockito.core.internal.spy.SpySpringockitoPostProcessor.postProcessAfterInitialization(SpySpringockitoPostProcessor.java:19)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:422)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1583)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
... 94 common frames omitted
Caused by: java.lang.IllegalStateException: Failed to load interface org.mockito.plugins.MockMaker implementation declared in sun.misc.CompoundEnumeration@4d68b571
at org.mockito.internal.configuration.plugins.PluginLoader.loadImpl(PluginLoader.java:101)
at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:45)
at org.mockito.internal.configuration.plugins.PluginRegistry.<init>(PluginRegistry.java:18)
at org.mockito.internal.configuration.plugins.Plugins.<clinit>(Plugins.java:17)
at org.mockito.internal.util.MockUtil.<clinit>(MockUtil.java:24)
... 103 common frames omitted
Caused by: 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.31-b07
JVM name : Java HotSpot(TM) 64-Bit Server VM
JVM version : 1.8.0_31-b13
JVM info : mixed mode
OS name : Windows Server 2008 R2
OS version : 6.1
at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.<init>(InlineByteBuddyMockMaker.java:172)
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:96)
... 107 common frames omitted
Caused by: java.lang.IllegalStateException: Error during attachment using: net.bytebuddy.agent.ByteBuddyAgent$AttachmentProvider$Compound@7f68a719
at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:366)
at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:332)
at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:300)
at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:286)
at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.<clinit>(InlineByteBuddyMockMaker.java:102)
... 113 common frames omitted
Caused by: java.lang.reflect.InvocationTargetException: null
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 net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:353)
... 117 common frames omitted
Caused by: com.sun.tools.attach.AttachNotSupportedException: no providers installed
at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:208)
... 122 common frames omitted
Removing jmockit from classpath solves the problem. But we are looking for solution which can help us continue using this tools together.
<mockito-core.version>2.7.13</mockito-core.version>
About this issue
- Original URL
- State: open
- Created 7 years ago
- Comments: 29 (9 by maintainers)
I’ve found a workaround for the issue adding this in your gradle file as dependency:
testImplementation files(Jvm.current().toolsJar)
This is working for me and I can have mockito with inline extension and jmockit together.Maven way
I seem to be having some similar issues, running on Linux with the latest Oracle JDK:
Did you try to add the tools jar dependencies? I am wondering if this is another JAVA_HOME issue. Could you check if there is a tools.jar file in the Docker image’s JDK installation?
Same here, working on openjdk:8 docker image.
see https://github.com/jmockit/jmockit1/issues/480#event-1349779862
Tried, but seems like nobody is interested in that there. My question why they simply close the issue was deleted and the issue locked… But as stated above - actual powermock milestone works fine with latest mockito for us. So no need for JMockit anymore. Dependency removed and blacklisted.
I assume that you are running a JVM and not a JDK on Windows. Did you check your
PATH
variable and yourJAVA_HOME
? The JVM complains that no attachment providers are available for the current VM what is typically the case for JVM installations.