I have a bunch of Spring Boot 2.5.6 applications that use Mockito for unit testing. The version of Mockito that is used is the one that comes shipped within SB itself (3.9.0). The JDK is OpenJDK 11.0.12+0. Everything was working fine until yesterday, this morning I suddenly cannot run any Mockito-based tests, all of them fail with the following:
Caused by: java.lang.IllegalStateException: Failed to load interface org.mockito.plugins.MockMaker implementation declared in java.lang.CompoundEnumeration@7c51f34b
Caused by: java.lang.reflect.InvocationTargetException
Caused by: org.mockito.exceptions.base.MockitoInitializationException:
Could not initialize inline Byte Buddy mock maker.
It appears as if your JDK does not supply a working agent attachment mechanism.
Java : 11
JVM vendor name : Homebrew
JVM vendor version : 11.0.12+0
JVM name : OpenJDK 64-Bit Server VM
JVM version : 11.0.12+0
JVM info : mixed mode
OS name : Mac OS X
OS version : 12.0.1
Caused by: java.lang.IllegalStateException: Could not self-attach to current VM using external process
I cannot identify anything that has changed between yesterday and today.
Things I have tried with no success:
- Re-run with Java 17.
- Re-install Java 11.
- Install a JDK 11 from a different vendor (Microsoft OpenJDK)
- Add
-Djdk.attach.allowAttachSelf=true
, both to command line and to<argLine>
parameter within surefire configuration, as suggested here - Add
-XX:+StartAttachListener
as suggested here - Restart the computer
- Ensure the firewall allows the
java
process to receive incoming connections as per here - (Temporarily) stop any security software that may prevent connections from happening
- Review
JAVA_HOME
and the different Java installations on my machine in case the process was trying to attach to the wrong Java as per here
In case it matters, this is on an MBP M1. Other members of the team are able to build with no problem.