Hello,
After upgrading to Java Agent 1.56 Instrumentation stopped working. It works fine with 1.55.6.
Java version: 26.0.1+8-FR (Amazon.com Inc.) Linux 6.12.88-119.157.amzn2023.x86_64
Tomcat version: 10.1.55
Linux: Alpine 3.24
On startup every we get a stack trace for every instrumentation ( 4k lines of stack traces)
[main] WARN co.elastic.apm.agent.bci.bytebuddy.InstallationListenerImpl - Byte Buddy warmup ended without transforming at least one class. The agent may not work as expected.
2026-06-25 15:44:38.4702026-06-25 13:44:38,469 [main] ERROR co.elastic.apm.agent.bci.ElasticApmAgent - Exception occurred while applying instrumentation co.elastic.apm.agent.java_ldap.LdapClientInstrumentation
2026-06-25 15:44:38.470 at co.elastic.apm.agent.bci.IndyBootstrap.getIndyBootstrapMethod(IndyBootstrap.java:234) ~[elastic-apm-agent.jar:1.56.0]
2026-06-25 15:44:38.470 at co.elastic.apm.agent.bci.IndyBootstrap.initIndyBootstrap(IndyBootstrap.java:268) ~[elastic-apm-agent.jar:1.56.0]
2026-06-25 15:44:38.470 at co.elastic.apm.agent.bci.IndyBootstrap.loadClassInBootstrap(IndyBootstrap.java:310) ~[elastic-apm-agent.jar:1.56.0]
2026-06-25 15:44:38.470 at net.bytebuddy.dynamic.loading.ClassInjector$AbstractBase.injectRaw(ClassInjector.java:202) ~[elastic-apm-agent.jar:1.56.0]
2026-06-25 15:44:38.470 at net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe.injectRaw(ClassInjector.java:1907) ~[elastic-apm-agent.jar:1.56.0]
2026-06-25 15:44:38.470 at net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe$Dispatcher$Unavailable.initialize(ClassInjector.java:2206) ~[elastic-apm-agent.jar:1.56.0]
2026-06-25 15:44:38.470 at co.elastic.apm.agent.premain.AgentMain.premain(AgentMain.java:47) [elastic-apm-agent.jar:1.56.0]
2026-06-25 15:44:38.470 at co.elastic.apm.agent.premain.AgentMain.init(AgentMain.java:98) [elastic-apm-agent.jar:1.56.0]
2026-06-25 15:44:38.470 at co.elastic.apm.agent.premain.AgentMain.loadAndInitializeAgent(AgentMain.java:157) [elastic-apm-agent.jar:1.56.0]
2026-06-25 15:44:38.470 at co.elastic.apm.agent.bci.ElasticApmAgent.initialize(ElasticApmAgent.java:165) [elastic-apm-agent.jar:1.56.0]
2026-06-25 15:44:38.470 at co.elastic.apm.agent.bci.ElasticApmAgent.initInstrumentation(ElasticApmAgent.java:179) [elastic-apm-agent.jar:1.56.0]
2026-06-25 15:44:38.470 at co.elastic.apm.agent.bci.ElasticApmAgent.initInstrumentation(ElasticApmAgent.java:290) [elastic-apm-agent.jar:1.56.0]
2026-06-25 15:44:38.470 at co.elastic.apm.agent.bci.ElasticApmAgent.initAgentBuilder(ElasticApmAgent.java:365) [elastic-apm-agent.jar:1.56.0]
2026-06-25 15:44:38.470 at co.elastic.apm.agent.bci.ElasticApmAgent.applyAdvice(ElasticApmAgent.java:444) ~[elastic-apm-agent.jar:1.56.0]
2026-06-25 15:44:38.470 at co.elastic.apm.agent.bci.ElasticApmAgent.getTransformer(ElasticApmAgent.java:486) ~[elastic-apm-agent.jar:1.56.0]
2026-06-25 15:44:38.470 at co.elastic.apm.agent.bci.IndyBootstrap.getIndyBootstrapMethod(IndyBootstrap.java:240) ~[elastic-apm-agent.jar:1.56.0]
Thank you
Thanks for reporting this, I will attempt to reproduce it on our end.
Can you help me clarify the following details:
- how does the java agent is attached to the tomcat server, is that through `-javaagent` JVM command line argument.
- it should happen very quickly at startup, can you confirm this ?
- does it happen even when no webapp is deployed on the tomcat server ? If yes, then it means it should be easier for us to reproduce.
- is it limited to a few instrumentations or do you see it on all of them ?
- do you have other environments where this issue is not being triggered, for example with different JVM versions
Using the following configuration I did not manage to reproduce it on my side yet:
- tomcat 10.1.20
- JDK 26.0.1
- apm agent version 1.56.1-SNAPSHOT (should be identical to the 1.56.0 release)
Apart from the noisy messages, is there any impact on the application or behavior of the agent to capture traces ?
Well, I was too fast to conclude on my previous message.
I managed to reproduce it with JDK 26, we get error messages like the following:
2026-06-25 17:22:20,878 [main] ERROR co.elastic.apm.agent.bci.ElasticApmAgent - Exception occurred while applying instrumentation co.elastic.apm.agent.java_ldap.LdapClientInstrumentation
java.lang.RuntimeException: java.lang.UnsupportedOperationException: Could not access Unsafe class: As of Java 26, using Unsafe is disabled by default, set net.bytebuddy.safe to true if you want to use the JVM's internal unsafe API even though it will become unsupported in the future and should be replaced by injection using method handles: net.bytebuddy.dynamic.loading.ClassInjector$UsingLookup
at co.elastic.apm.agent.bci.IndyBootstrap.getIndyBootstrapMethod(IndyBootstrap.java:240) ~[elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.bci.ElasticApmAgent.getTransformer(ElasticApmAgent.java:486) ~[elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.bci.ElasticApmAgent.applyAdvice(ElasticApmAgent.java:444) ~[elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.bci.ElasticApmAgent.initAgentBuilder(ElasticApmAgent.java:365) [elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.bci.ElasticApmAgent.initInstrumentation(ElasticApmAgent.java:290) [elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.bci.ElasticApmAgent.initInstrumentation(ElasticApmAgent.java:179) [elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.bci.ElasticApmAgent.initialize(ElasticApmAgent.java:165) [elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:565) ~[?:?]
at co.elastic.apm.agent.premain.AgentMain.loadAndInitializeAgent(AgentMain.java:157) [elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.premain.AgentMain.init(AgentMain.java:98) [elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.premain.AgentMain.premain(AgentMain.java:47) [elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:565) ~[?:?]
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:544) [?:?]
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:556) [?:?]
Caused by: java.lang.UnsupportedOperationException: Could not access Unsafe class: As of Java 26, using Unsafe is disabled by default, set net.bytebuddy.safe to true if you want to use the JVM's internal unsafe API even though it will become unsupported in the future and should be replaced by injection using method handles: net.bytebuddy.dynamic.loading.ClassInjector$UsingLookup
at net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe$Dispatcher$Unavailable.initialize(ClassInjector.java:2206) ~[elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe.injectRaw(ClassInjector.java:1907) ~[elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at net.bytebuddy.dynamic.loading.ClassInjector$AbstractBase.injectRaw(ClassInjector.java:202) ~[elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.bci.IndyBootstrap.loadClassInBootstrap(IndyBootstrap.java:310) ~[elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.bci.IndyBootstrap.initIndyBootstrap(IndyBootstrap.java:268) ~[elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
at co.elastic.apm.agent.bci.IndyBootstrap.getIndyBootstrapMethod(IndyBootstrap.java:234) ~[elastic-apm-agent-1.56.1-SNAPSHOT.jar:1.56.1-SNAPSHOT]
... 15 more
You should be able to use -Dnet.bytebuddy.safe=false in your JVM CLI as a temporary work-around for this.
Hello,
Can you help me clarify the following details:
- how does the java agent is attached to the tomcat server, is that through `-javaagent` JVM command line argument.
yes
- it should happen very quickly at startup, can you confirm this ?
yes
- does it happen even when no webapp is deployed on the tomcat server ? If yes, then it means it should be easier for us to reproduce.
hard to test as we deploy the docker container with the app already deployed.
- is it limited to a few instrumentations or do you see it on all of them ?
all of them.
- do you have other environments where this issue is not being triggered, for example with different JVM versions
Works fine with java-25 / tomcat
- Apart from the noisy messages, is there any impact on the application or behavior of the agent to capture traces ?
Yes..no traces are sent/present to the stack. No trace id / transaction ids are present in the logs. There is still jvm related information being sent (heap, threads etc..)
-Dnet.bytebuddy.safe=false
This fixes the problem.
Thank you
I've opened an issue so we can investigate further: UnsupportedOperationException at startup when using JDK 26+ · Issue #4519 · elastic/apm-agent-java · GitHub
You can subscribe to it so you'll get notified when it's fixed or when a snapshot might be available for testing.