mockk: Bug: IllegalStateException: Could not self-attach to current VM using external process on Open JDK 11.0.1
We have main code in Java and tests in Kotlin. We build it and run the tests inside Docker container. All works locally but it does not work in our build environment. We have a Jenkins master running on AWS. It calls a slave node (also on AWS) to run the build. The build fails because of this library with the following error:
[WARNING] Corrupted STDOUT by directly writing to native stream in forked JVM 1. See FAQ web page and the dump file /home/mbuilder/workspace/....dumpstream
java.lang.ExceptionInInitializerError
Caused by: java.lang.IllegalStateException: Could not self-attach to current VM using external process
java.lang.NoClassDefFoundError: Could not initialize class io.mockk.impl.JvmMockKGateway
The dumpstream file is attached 2019-02-12T15-01-39_092-jvmRun1.dumpstream(had to add .log
extention for GitHub).
Also, note that OurClassTest
mentioned in the dumpstream is only 283 lines long, so there is no line 290 that is referenced there.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 32
I’ve received this error:
java.lang.NoClassDefFoundError: Could not initialize class io.mockk.impl.JvmMockKGateway
after upgrading to AS Arctic Fox using mockk 1.10.2
@oleksiyp so the code could just contain a single test with
mockk<Serializable>()
and the docker image is the following:Then we run it like this (in the Jenkisfile):
MockK uses a bit different way(inlining) then Mockito uses by default(subclassing) to overcome
final classes
problem.Try switching mockito to inlining mode https://hadihariri.com/2016/10/04/Mocking-Kotlin-With-Mockito/#mockmaker. It probably will have same thing.
Anyway I am reopening ticket. Just want let you know that I check such things during weekends(and even not during each weekend). So please be patient