New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttachNotSupportedException: no providers installed. When using mock-maker-inline extension and jmockit.jar is found in classpath on Windows. #978

Open
yeskov opened this Issue Mar 6, 2017 · 20 comments

Comments

Projects
None yet
7 participants
@yeskov

yeskov commented Mar 6, 2017

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>

@TimvdLippe

This comment has been minimized.

Contributor

TimvdLippe commented Mar 10, 2017

JVM version : 1.8.0_31-b13 shows that you are using a fairly old version of Java. Could you update to a more recent version? The earlier JVM's are known to have fairly big bugs that affect the usage of Mockito.

@yeskov

This comment has been minimized.

yeskov commented Mar 14, 2017

We started update. I will respond when results become available.

@yeskov

This comment has been minimized.

yeskov commented Mar 15, 2017

Hello.
We updated to JVM 1.8.0_121-b13 but issue is still reproducing.

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.$Proxy43.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.mock(Mockito.java:1705)
	at org.kubek2k.springockito.core.internal.mock.MockFactorySpringockito.getObject(MockFactorySpringockito.java:26)
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
	... 117 common frames omitted
Caused by: java.lang.IllegalStateException: Failed to load interface org.mockito.plugins.MockMaker implementation declared in sun.misc.CompoundEnumeration@47c64cfe
	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)
	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)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
	at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:634)
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:140)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1143)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1046)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
	... 42 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.121-b13
JVM name           : Java HotSpot(TM) 64-Bit Server VM
JVM version        : 1.8.0_121-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:423)
	at java.lang.Class.newInstance(Class.java:442)
	at org.mockito.internal.configuration.plugins.PluginLoader.loadImpl(PluginLoader.java:96)
	... 74 common frames omitted
Caused by: java.lang.IllegalStateException: Error during attachment using: net.bytebuddy.agent.ByteBuddyAgent$AttachmentProvider$Compound@12b526c0
	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)
	... 80 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:498)
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:353)
	... 84 common frames omitted
Caused by: com.sun.tools.attach.AttachNotSupportedException: no providers installed
	at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:208)
	... 89 common frames omitted
@raphw

This comment has been minimized.

Member

raphw commented Mar 30, 2017

I assume that you are running a JVM and not a JDK on Windows. Did you check your PATH variable and your JAVA_HOME? The JVM complains that no attachment providers are available for the current VM what is typically the case for JVM installations.

@bbarker

This comment has been minimized.

bbarker commented Jul 18, 2017

I seem to be having some similar issues, running on Linux with the latest Oracle JDK:

2017-07-18 12:20:45
Full thread dump OpenJDK 64-Bit Server VM (25.131-b11 mixed mode):

"Service Thread" #10 daemon prio=9 os_prio=0 tid=0x00007faf142c0000 nid=0x1e91 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C1 CompilerThread3" #9 daemon prio=9 os_prio=0 tid=0x00007faf142bd000 nid=0x1e90 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread2" #8 daemon prio=9 os_prio=0 tid=0x00007faf142bb000 nid=0x1e8f waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" #7 daemon prio=9 os_prio=0 tid=0x00007faf142b8800 nid=0x1e8e runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" #6 daemon prio=9 os_prio=0 tid=0x00007faf142b6800 nid=0x1e8d waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Monitor Ctrl-Break" #5 daemon prio=5 os_prio=0 tid=0x00007faf142b5000 nid=0x1e8c runnable [0x00007faee3387000]
   java.lang.Thread.State: RUNNABLE
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
	at java.net.SocketInputStream.read(SocketInputStream.java:171)
	at java.net.SocketInputStream.read(SocketInputStream.java:141)
	at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
	at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
	at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
	- locked <0x0000000718ebbfc0> (a java.io.InputStreamReader)
	at java.io.InputStreamReader.read(InputStreamReader.java:184)
	at java.io.BufferedReader.fill(BufferedReader.java:161)
	at java.io.BufferedReader.readLine(BufferedReader.java:324)
	- locked <0x0000000718ebbfc0> (a java.io.InputStreamReader)
	at java.io.BufferedReader.readLine(BufferedReader.java:389)
	at com.intellij.rt.execution.application.AppMainV2$1.run(AppMainV2.java:64)

"Signal Dispatcher" #4 daemon prio=9 os_prio=0 tid=0x00007faf14208000 nid=0x1e8b waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" #3 daemon prio=8 os_prio=0 tid=0x00007faf141df800 nid=0x1e83 in Object.wait() [0x00007faee38f7000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <0x0000000718c08ec8> (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
	- locked <0x0000000718c08ec8> (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164)
	at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)

"Reference Handler" #2 daemon prio=10 os_prio=0 tid=0x00007faf141db000 nid=0x1e82 in Object.wait() [0x00007faee39f8000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <0x0000000718c06b68> (a java.lang.ref.Reference$Lock)
	at java.lang.Object.wait(Object.java:502)
	at java.lang.ref.Reference.tryHandlePending(Reference.java:191)
	- locked <0x0000000718c06b68> (a java.lang.ref.Reference$Lock)
	at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:153)

"main" #1 prio=5 os_prio=0 tid=0x00007faf14016800 nid=0x1e73 runnable [0x00007faf1bfa6000]
   java.lang.Thread.State: RUNNABLE
	at sun.tools.attach.HotSpotVirtualMachine.attachTimeout(HotSpotVirtualMachine.java:335)
	- locked <0x000000071b086b40> (a sun.tools.attach.LinuxVirtualMachine)
	at sun.tools.attach.LinuxVirtualMachine.<init>(LinuxVirtualMachine.java:97)
	at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttachProvider.java:63)
	at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:208)
	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:498)
	at net.bytebuddy.agent.Attacher.install(Attacher.java:78)
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:374)
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:353)
	- locked <0x000000071ac2d1a8> (a java.lang.Class for net.bytebuddy.agent.ByteBuddyAgent)
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:321)
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:307)
	at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.<clinit>(InlineByteBuddyMockMaker.java:102)
	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:423)
	at java.lang.Class.newInstance(Class.java:442)
	at org.mockito.internal.configuration.plugins.PluginLoader.loadImpl(PluginLoader.java:96)
	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)
	at org.mockito.internal.util.MockCreationValidator.validateType(MockCreationValidator.java:22)
	at org.mockito.internal.creation.MockSettingsImpl.validatedSettings(MockSettingsImpl.java:186)
	at org.mockito.internal.creation.MockSettingsImpl.confirm(MockSettingsImpl.java:180)
	at org.mockito.internal.MockitoCore.mock(MockitoCore.java:62)
	at org.mockito.Mockito.mock(Mockito.java:1729)
	at org.mockito.Mockito.mock(Mockito.java:1642)
	at edu.cornell.ansci.dairy.econ.model.CowIT.<init>(CowIT.scala:15)
	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:423)
	at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:217)
	at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

"VM Thread" os_prio=0 tid=0x00007faf141d3800 nid=0x1e80 runnable 

"GC task thread#0 (ParallelGC)" os_prio=0 tid=0x00007faf1402c000 nid=0x1e74 runnable 

"GC task thread#1 (ParallelGC)" os_prio=0 tid=0x00007faf1402d800 nid=0x1e75 runnable 

"GC task thread#2 (ParallelGC)" os_prio=0 tid=0x00007faf1402f800 nid=0x1e76 runnable 

"GC task thread#3 (ParallelGC)" os_prio=0 tid=0x00007faf14031000 nid=0x1e77 runnable 

"GC task thread#4 (ParallelGC)" os_prio=0 tid=0x00007faf14033000 nid=0x1e78 runnable 

"GC task thread#5 (ParallelGC)" os_prio=0 tid=0x00007faf14034800 nid=0x1e79 runnable 

"GC task thread#6 (ParallelGC)" os_prio=0 tid=0x00007faf14036800 nid=0x1e7a runnable 

"GC task thread#7 (ParallelGC)" os_prio=0 tid=0x00007faf14038000 nid=0x1e7b runnable 

"VM Periodic Task Thread" os_prio=0 tid=0x00007faf142c2800 nid=0x1e92 waiting on condition 

JNI global references: 32

Heap
 PSYoungGen      total 150016K, used 38720K [0x0000000718c00000, 0x0000000723300000, 0x00000007c0000000)
  eden space 129024K, 30% used [0x0000000718c00000,0x000000071b1d00d0,0x0000000720a00000)
  from space 20992K, 0% used [0x0000000721e80000,0x0000000721e80000,0x0000000723300000)
  to   space 20992K, 0% used [0x0000000720a00000,0x0000000720a00000,0x0000000721e80000)
 ParOldGen       total 343040K, used 0K [0x00000005ca400000, 0x00000005df300000, 0x0000000718c00000)
  object space 343040K, 0% used [0x00000005ca400000,0x00000005ca400000,0x00000005df300000)
 Metaspace       used 6289K, capacity 6382K, committed 6400K, reserved 1056768K
  class space    used 738K, capacity 761K, committed 768K, reserved 1048576K


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.$Proxy5.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:186)
	at org.mockito.internal.creation.MockSettingsImpl.confirm(MockSettingsImpl.java:180)
	at org.mockito.internal.MockitoCore.mock(MockitoCore.java:62)
	at org.mockito.Mockito.mock(Mockito.java:1729)
	at org.mockito.Mockito.mock(Mockito.java:1642)
	at edu.cornell.ansci.dairy.econ.model.CowIT.<init>(CowIT.scala:15)
	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:423)
	at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:217)
	at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.IllegalStateException: Failed to load interface org.mockito.plugins.MockMaker implementation declared in sun.misc.CompoundEnumeration@43814d18
	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)
	... 28 more
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.131-b11
JVM name           : OpenJDK 64-Bit Server VM
JVM version        : 1.8.0_131-8u131-b11-0ubuntu1.16.04.2-b11
JVM info           : mixed mode
OS name            : Linux
OS version         : 4.4.0-81-generic

	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:423)
	at java.lang.Class.newInstance(Class.java:442)
	at org.mockito.internal.configuration.plugins.PluginLoader.loadImpl(PluginLoader.java:96)
	... 32 more
Caused by: java.lang.IllegalStateException: Error during attachment using: net.bytebuddy.agent.ByteBuddyAgent$AttachmentProvider$Compound@2c5f400c
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:379)
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:353)
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:321)
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:307)
	at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.<clinit>(InlineByteBuddyMockMaker.java:102)
	... 38 more
Caused by: java.lang.reflect.InvocationTargetException
	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:498)
	at net.bytebuddy.agent.Attacher.install(Attacher.java:78)
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:374)
	... 42 more
Caused by: com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded
	at sun.tools.attach.LinuxVirtualMachine.<init>(LinuxVirtualMachine.java:106)
	at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttachProvider.java:63)
	at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:208)
	... 48 more


Process finished with exit code 255
@bbarker

This comment has been minimized.

bbarker commented Jul 18, 2017

After looking at https://stackoverflow.com/questions/5769877/attachnotsupportedexception-due-to-missing-java-pid-file-in-attach-api, there seem to be a few possible concerns. The most obvious one noted (running jvm processes as the same user) shouldn't be an issue in my case.

Edit: also i should note this is in no way an android application.

@bbarker

This comment has been minimized.

@bbarker

This comment has been minimized.

bbarker commented Oct 26, 2017

Hmm, on a Linux system now (again, nothing to do with Android, I'm getting:

[INFO] Running edu.cornell.ansci.dairy.econ.model.CowTest
[ERROR] Tests run: 16, Failures: 0, Errors: 16, Skipped: 0, Time elapsed: 0.152 s <<< FAILURE! - in edu.cornell.ansci.dairy.econ.model.CowTest
[ERROR] processSimulationTest(edu.cornell.ansci.dairy.econ.model.CowTest)  Time elapsed: 0.008 s  <<< ERROR!
java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker
        at edu.cornell.ansci.dairy.econ.model.CowTest.<init>(CowTest.scala:23)
Caused by: java.lang.IllegalStateException: Failed to load interface org.mockito.plugins.MockMaker implementation declared in sun.misc.CompoundEnumeration@48503868
        at edu.cornell.ansci.dairy.econ.model.CowTest.<init>(CowTest.scala:23)
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.144-b01
JVM name           : OpenJDK 64-Bit Server VM
JVM version        : 1.8.0_144-01
JVM info           : mixed mode
OS name            : Linux
OS version         : 4.10.0-37-generic

        at edu.cornell.ansci.dairy.econ.model.CowTest.<init>(CowTest.scala:23)
Caused by: java.lang.IllegalStateException: No compatible attachment provider is not available
        at edu.cornell.ansci.dairy.econ.model.CowTest.<init>(CowTest.scala:23)

This particular test only seems to use imports from org.mockito and org.hamcrest with regard to mocking (no powermock, though I have it elsewhere in my project).

Oddly, the test will work if I run it directly from intellij as part of the JUnit test runner, but fails if I run it from maven.

@raphw

This comment has been minimized.

Member

raphw commented Oct 28, 2017

It seems like attachment does not work as it cannot locate tools.jar. Is your java.home property set correctly?

@mbogner

This comment has been minimized.

mbogner commented Nov 7, 2017

Hello,

I tried using Mockito with the MockMaker extension and JMockit in the same project. If JMockit is found on the classpath I get the exceptions below. The build is running on an actual Ubuntu 16.04 LTS with latest Oracle JDK 8u152 triggered by a Jenkins server with gradle 4.2.1.

If someone would tell me how to add -XX:+StartAttachListener to my gradle build would be nice - then I would give It a try.

gradle.properties:

...
    testCompile group: 'org.mockito', name: 'mockito-core', version: '2.11.0'
    testCompile group: 'org.jmockit', name: 'jmockit', version: '1.36.1'
..

stacktrace:

java.lang.IllegalStateException: Failed to load ApplicationContext
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
	at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
	at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:189)
	at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:131)
	at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:114)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:57)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:66)
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
	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:498)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
	at com.sun.proxy.$Proxy1.processTestClass(Unknown Source)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:108)
	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:498)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:146)
	at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:128)
	at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
	at java.lang.Thread.run(Thread.java:748)
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:60)
	at com.sun.proxy.$Proxy29.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:204)
	at org.mockito.internal.creation.MockSettingsImpl.build(MockSettingsImpl.java:198)
	at org.mockito.internal.MockitoCore.mock(MockitoCore.java:64)
	at org.mockito.Mockito.mock(Mockito.java:1821)
	at org.springframework.boot.test.mock.mockito.MockDefinition.createMock(MockDefinition.java:157)
	at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.createMock(MockitoPostProcessor.java:225)
	at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.registerMock(MockitoPostProcessor.java:195)
	at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.register(MockitoPostProcessor.java:177)
	at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.postProcessBeanFactory(MockitoPostProcessor.java:147)
	at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.postProcessBeanFactory(MockitoPostProcessor.java:134)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:281)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:169)
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525)
	at org.springframework.test.context.web.AbstractGenericWebContextLoader.loadContext(AbstractGenericWebContextLoader.java:134)
	at org.springframework.test.context.web.AbstractGenericWebContextLoader.loadContext(AbstractGenericWebContextLoader.java:61)
	at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:108)
	at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:251)
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)
	... 48 more
Caused by: java.lang.IllegalStateException: Failed to load interface org.mockito.plugins.MockMaker implementation declared in sun.misc.CompoundEnumeration@5bc57220
	at org.mockito.internal.configuration.plugins.PluginLoader.loadImpl(PluginLoader.java:94)
	at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:48)
	at org.mockito.internal.configuration.plugins.PluginRegistry.<init>(PluginRegistry.java:20)
	at org.mockito.internal.configuration.plugins.Plugins.<clinit>(Plugins.java:18)
	at org.mockito.internal.util.MockUtil.<clinit>(MockUtil.java:24)
	... 69 more
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.152-b16
JVM name           : Java HotSpot(TM) 64-Bit Server VM
JVM version        : 1.8.0_152-b16
JVM info           : mixed mode
OS name            : Linux
OS version         : 4.4.0-97-generic

	at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.<init>(InlineByteBuddyMockMaker.java:171)
	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:423)
	at java.lang.Class.newInstance(Class.java:442)
	at org.mockito.internal.configuration.plugins.PluginLoader.loadImpl(PluginLoader.java:89)
	... 73 more
Caused by: java.lang.IllegalStateException: Error during attachment using: net.bytebuddy.agent.ByteBuddyAgent$AttachmentProvider$Compound@76bcd7e6
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:378)
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:352)
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:320)
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:306)
	at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.<clinit>(InlineByteBuddyMockMaker.java:101)
	... 79 more
Caused by: java.lang.reflect.InvocationTargetException
	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:498)
	at net.bytebuddy.agent.Attacher.install(Attacher.java:77)
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:373)
	... 83 more
Caused by: com.sun.tools.attach.AttachNotSupportedException: no providers installed
	at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:202)
	... 89 more

Any suggestions welcome =) Trying to add JMockit for static class mocks. Also tried PowerMock, but this seems to be incompatible with latest Mockito.

@raphw

This comment has been minimized.

Member

raphw commented Nov 8, 2017

That is strange as the exceptions root seems to come from the JVM:

Caused by: com.sun.tools.attach.AttachNotSupportedException: no providers installed

I have no idea how this can be caused by using JMockit other than that it might install its own agent and break the self-attachment mechanism somehow. Have you consulted their mailing list?

@mbogner

This comment has been minimized.

mbogner commented Nov 19, 2017

@raphw Not yet. I was looking into this because I could remember something about IBM JDK and stuff like that. But its a simple Ubuntu VM with Oracle JDK. No clue yet. But found out, that using powermock with an actual milestone works good enough for mocking static classes (hint for the others!!).
I think everybody would really appreciate having the possibility to do this in mockito directly instead of using other stuff like powermock or jmockit for this. Any chance to get this feature maybe as an extension like mocking final classes?

EDIT: posted again in jmockit/jmockit1#480

@mbogner

This comment has been minimized.

mbogner commented Nov 21, 2017

Wrote a simple reproducer for this. It is working on my Mac running with High Sierra and Java version (8u152). The build server (ubuntu 16.04LTS with all updates) has the same.
Also attached the whole build output from "./gradlew clean build --debug --stacktrace".

reproducer.zip
error.log.zip

@raphw

This comment has been minimized.

Member

raphw commented Nov 21, 2017

Ok, it seems like the JMockit library copied some classes from the VM into its jar file and this blows up the attachment attempt as Byte Buddy (and therefore Mockito) gets to see this bogus code. The jar contains classes that are not supposed to exist on the JVM and goes down the wrong path.

The reason this fails from gradle and not from IntelliJ are subtleties in class loading.

I suggest to report this to JMockit.

@mbogner

This comment has been minimized.

mbogner commented Dec 1, 2017

see jmockit/jmockit1#480 (comment)

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.

@themanol

This comment has been minimized.

themanol commented Jul 27, 2018

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.

@nan140114

This comment has been minimized.

nan140114 commented Oct 22, 2018

Same here, working on openjdk:8 docker image.

@raphw

This comment has been minimized.

Member

raphw commented Oct 22, 2018

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?

@nan140114

This comment has been minimized.

nan140114 commented Oct 22, 2018

Hello thanks for reply. I can't see the Dockerfile, but inside the container there is a tools.jar in the path:

$ ls /usr/lib/jvm/java-8-openjdk-amd64/lib/
amd64 ct.sym dt.jar ir.idl jconsole.jar jexec orb.idl sa-jdi.jar tools.jar

but the JAVA env vars apparently don't point to that folder:

JAVA_HOME=/docker-java-home
JAVA_VERSION=8u181
GRADLE_HOME=/opt/gradle

At /docker-java-home dir there is a tools.jar file
ls /docker-java-home/lib/
amd64 ct.sym dt.jar ir.idl jconsole.jar jexec orb.idl sa-jdi.jar tools.jar

what do u think? it's a JAVA_HOME issue? than you in advance.

@raphw

This comment has been minimized.

Member

raphw commented Oct 23, 2018

Byte Buddy is using the java.home system property. It looks at several knwon relative locations from there: https://github.com/raphw/byte-buddy/blob/master/byte-buddy-agent/src/main/java/net/bytebuddy/agent/ByteBuddyAgent.java#L822

Maybe the file is not readable to the JVM process or something like that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment