APM Java agent exception at startup

Elasticsearch version: 7.8

APM Server version: 7.8

APM Agent language and version: JAva 1.18

Hi,
I'm trying to use the latest APM Java agent (1.18) but I'm facing this error:

ERROR co.elastic.apm.agent.util.DependencyInjectingServiceLoader - unable to instantiate 'co.elastic.apm.agent.httpclient.HttpClientAsyncInstrumentation', unsupported class version error: co/elastic/apm/agent/httpclient/HttpClientAsyncInstrumentation has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

to be honest, I read articles and searched it also here but...is there anyone can help me to understand it and explain it? I mean, can I fix it anyway?
is it an error that can I ignore or not?

What java version are you using ?

Java 1.8.0_242

Major version numbers map to Java versions:

  • 45 = Java 1.1
  • 46 = Java 1.2
  • 47 = Java 1.3
  • 48 = Java 1.4
  • 49 = Java 5
  • 50 = Java 6
  • 51 = Java 7
  • 52 = Java 8
  • 53 = Java 9
  • 54 = Java 10
  • 55 = Java 11
  • 56 = Java 12
  • 57 = Java 13

You are using java 8 ( class file version 52.0) to run a class build with java 11 ( class file version 55.0)

1 Like

You can safely ignore that error. We've set the log level for that to debug now instead of error.

1 Like

thanks everybody

Having same issue, JDK 1.8.0_265 Azul OpenJDK APM 1.18.0, doesn't work at all, and confused as to wether it should.

1 Like

Thanks for the feedback @felixbarny. Does that then mean it is not a problem? and the deployment should work successfully

I have exactly the same issue in my deployment. APM agent is able to successfully run healthchecks against the APM Server, but never posts events successfully to the apm server. when it attempts to post a /intake/v2/events call, it always fails with

java.io.IOException: Error writing request body to serve

If you check the communication between the agent and the server with a tcpdump, you would notice the agent never sent anthing over the wire to the apm server. What do you think? i have actually logged the issue here

Yes.
The unsupported class version error and java.io.IOException: Error writing request body to server are definitely not related.

JDK 1.8.0_261
APM 1.18.0
Elastic Stack 7.9.2

If I use a version greater than 4.5.1 for JNA the APM agent does not work, with the following error

[INFO] Attaching agents: []
Exception in thread "main" java.lang.IllegalStateException: Error during attachment using: co.elastic.apm.attach.bytebuddy.agent.ByteBuddyAgent$AttachmentProvider$Compound@dbd940d
** at co.elastic.apm.attach.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:613)**
** at co.elastic.apm.attach.bytebuddy.agent.ByteBuddyAgent.attach(ByteBuddyAgent.java:273)**
** at co.elastic.apm.attach.ElasticApmAttacher.attach(ElasticApmAttacher.java:159)**
** at co.elastic.apm.attach.ElasticApmAttacher.attach(ElasticApmAttacher.java:113)**
** at co.elastic.apm.attach.ElasticApmAttacher.attach(ElasticApmAttacher.java:70)**
** at local.proxy.SecDNS.SecDnsApplication.main(SecDnsApplication.java:46)**
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 co.elastic.apm.attach.bytebuddy.agent.Attacher.install(Attacher.java:106)**
** at co.elastic.apm.attach.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:608)**
** ... 5 more**
Caused by: java.lang.NoSuchFieldError: SIZE
** at com.sun.jna.platform.win32.WinBase.(WinBase.java:52)**
** at com.sun.jna.platform.win32.WinNT$HANDLE.fromNative(WinNT.java:1366)**
** at com.sun.jna.NativeMappedConverter.fromNative(NativeMappedConverter.java:70)**
** at com.sun.jna.Function.invoke(Function.java:370)**
** at com.sun.jna.Library$Handler.invoke(Library.java:265)**
** at com.sun.proxy.$Proxy2.OpenProcess(Unknown Source)**
** at co.elastic.apm.attach.bytebuddy.agent.VirtualMachine$ForHotSpot$Connection$ForJnaWindowsNamedPipe$Factory.connect(VirtualMachine.java:1271)**
** at co.elastic.apm.attach.bytebuddy.agent.VirtualMachine$ForHotSpot.attach(VirtualMachine.java:256)**
** at co.elastic.apm.attach.bytebuddy.agent.VirtualMachine$ForHotSpot.attach(VirtualMachine.java:239)**
** ... 11 more**

If I use version 4.5.1 for JNA, the APM agent works but with the following errors:

2020-10-06 19:31:25,426 [Attach Listener] INFO co.elastic.apm.agent.util.JmxUtils - Found JVM-specific OperatingSystemMXBean interface: com.sun.management.OperatingSystemMXBean
2020-10-06 19:31:25,446 [Attach Listener] INFO co.elastic.apm.agent.configuration.StartupInfo - Starting Elastic APM 1.18.0 as SecurityProxyApplication on Java 1.8.0_261 Runtime version: 1.8.0_261-b12 VM version: 25.261-b12 (Oracle Corporation) Windows 10 10.0
> 2020-10-06 19:31:25,476 [Attach Listener] ERROR co.elastic.apm.agent.util.DependencyInjectingServiceLoader - unable to instantiate 'co.elastic.apm.agent.httpclient.HttpClientInstrumentation', unsupported class version error: co/elastic/apm/agent/httpclient/HttpClientInstrumentation has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
> 2020-10-06 19:31:25,476 [Attach Listener] ERROR co.elastic.apm.agent.util.DependencyInjectingServiceLoader - unable to instantiate 'co.elastic.apm.agent.httpclient.HttpClientAsyncInstrumentation', unsupported class version error: co/elastic/apm/agent/httpclient/HttpClientAsyncInstrumentation has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
> 2020-10-06 19:31:25,477 [Attach Listener] ERROR co.elastic.apm.agent.util.DependencyInjectingServiceLoader - unable to instantiate 'co.elastic.apm.agent.httpclient.HttpRequestHeadersInstrumentation', unsupported class version error: co/elastic/apm/agent/httpclient/HttpRequestHeadersInstrumentation has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
> 2020-10-06 19:31:26,591 [elastic-apm-server-healthcheck] INFO co.elastic.apm.agent.report.ApmServerHealthChecker - Elastic APM server is available: { "build_date": "2020-09-22T22:02:35Z", "build_sha": "34f81a2208c862777ca587867fd3aa2373c3f669", "version": "7.9.2"}
2020-10-06 19:31:26,679 [elastic-apm-remote-config-poller] INFO co.elastic.apm.agent.configuration.ApmServerConfigurationSource - Received new configuration from APM Server: {}
2020-10-06 19:31:27,117 [Attach Listener] INFO co.elastic.apm.agent.impl.ElasticApmTracer - Tracer switched to RUNNING state

Thanks for the report!
This not related to this topic though. Please create a new one or better, create an issue on the Byte Buddy repository: Issues · raphw/byte-buddy · GitHub