10

Recently I developed a java agent using byte buddy. The development in eclipse was fine, then I put the agent to production and the message:

No compatible attachment provider is available

along with some stacktraces originating from the lines

static {
  ByteBuddyAgent.install();
}
CoronA
  • 7,717
  • 2
  • 26
  • 53

2 Answers2

16

After some debugging I found the problem. The message "No compatible attachment provider is not available" occurs if the agent was called with a jre instead of a jdk.

Unfortunately calling java -version does not return whether java is a jdk or a jre (the message is displaying Java runtime Environment for both).

In my case (OS:Windows) it was tricky, because newer jsdk-installations attach C:\ProgramData\Oracle\Java\javapath to the system path, which contains a jre and not a jdk. The formerly added entry %JAVA_HOME%/bin got hidden through this modification. When I removed the entry C:\ProgramData\Oracle\Java\javapath everything worked fine.

CoronA
  • 7,717
  • 2
  • 26
  • 53
0

I've had the same problem starting a Spring Boot 2.3 application with a minimal JRE that was created with jlink. It would not start, and would keep throwing the following stacktrace:

Caused by: java.lang.IllegalStateException: No compatible attachment provider is available
    at reactor.tools.shaded.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:602)
    at reactor.tools.shaded.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:586)
    at reactor.tools.shaded.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:538)
    at reactor.tools.shaded.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:515)
    at reactor.tools.agent.ReactorDebugAgent.init(ReactorDebugAgent.java:56)

I found out that this ByteBuddyAgent (from this link) requires the java module jdk.attach to be included, which was not the case in my minimal JRE.

After adding the jdk.attach module to my jlink command under --add-modules, the error went away and I could start my Spring Boot application again.

Ajunne
  • 1
  • 1