# APM Java agent exception at startup

**URL:** <https://discuss.elastic.co/t/apm-java-agent-exception-at-startup/250208>\
**Category:** APM\
**Tags:** java\
**Created:** [September 28, 2020, 2:25pm UTC](https://discuss.elastic.co/t/apm-java-agent-exception-at-startup/250208 "2020-09-28T14:25:09Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![rschirin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rschirin/32/45283_2.png) [@rschirin](https://discuss.elastic.co/u/rschirin)\
**Post date:** [September 28, 2020, 2:25pm UTC](https://discuss.elastic.co/t/apm-java-agent-exception-at-startup/250208/1 "2020-09-28T14:25:09Z")

</div>

**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?

---

<div class="post-metadata">

**Author:** ![ylasri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ylasri/32/86120_2.png) [@ylasri](https://discuss.elastic.co/u/ylasri)\
**Post date:** [September 28, 2020, 2:30pm UTC](https://discuss.elastic.co/t/apm-java-agent-exception-at-startup/250208/2 "2020-09-28T14:30:37Z")

</div>

What java version are you using ?

---

<div class="post-metadata">

**Author:** ![rschirin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rschirin/32/45283_2.png) [@rschirin](https://discuss.elastic.co/u/rschirin)\
**Post date:** [September 28, 2020, 2:39pm UTC](https://discuss.elastic.co/t/apm-java-agent-exception-at-startup/250208/3 "2020-09-28T14:39:05Z")

</div>

Java 1.8.0\_242

---

<div class="post-metadata">

**Author:** ![ylasri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ylasri/32/86120_2.png) [@ylasri](https://discuss.elastic.co/u/ylasri)\
**Post date:** [September 28, 2020, 2:41pm UTC](https://discuss.elastic.co/t/apm-java-agent-exception-at-startup/250208/4 "2020-09-28T14:41:10Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [September 28, 2020, 3:02pm UTC](https://discuss.elastic.co/t/apm-java-agent-exception-at-startup/250208/5 "2020-09-28T15:02:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rschirin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rschirin/32/45283_2.png) [@rschirin](https://discuss.elastic.co/u/rschirin)\
**Post date:** [September 28, 2020, 3:15pm UTC](https://discuss.elastic.co/t/apm-java-agent-exception-at-startup/250208/6 "2020-09-28T15:15:29Z")

</div>

thanks everybody

---

<div class="post-metadata">

**Author:** ![scathatheworm](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@scathatheworm](https://discuss.elastic.co/u/scathatheworm)\
**Post date:** [October 1, 2020, 11:48am UTC](https://discuss.elastic.co/t/apm-java-agent-exception-at-startup/250208/7 "2020-10-01T11:48:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Dawn\_Okem](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dawn_okem/32/58264_2.png) [@Dawn\_Okem](https://discuss.elastic.co/u/Dawn_Okem)\
**Post date:** [October 6, 2020, 7:39am UTC](https://discuss.elastic.co/t/apm-java-agent-exception-at-startup/250208/8 "2020-10-06T07:39:36Z")

</div>

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](https://discuss.elastic.co/t/sending-payload-to-apm-server-failed/250912)

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [October 6, 2020, 8:59am UTC](https://discuss.elastic.co/t/apm-java-agent-exception-at-startup/250208/9 "2020-10-06T08:59:10Z")

</div>

> [@Dawn\_Okem](#):
>
> Does that then mean it is not a problem? and the deployment should work successfully

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

---

<div class="post-metadata">

**Author:** ![gerardnorton](https://avatars.discourse-cdn.com/v4/letter/g/a88e57/32.png) [@gerardnorton](https://discuss.elastic.co/u/gerardnorton)\
**Post date:** [October 6, 2020, 5:43pm UTC](https://discuss.elastic.co/t/apm-java-agent-exception-at-startup/250208/10 "2020-10-06T17:43:51Z")

</div>

**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

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [October 7, 2020, 7:36am UTC](https://discuss.elastic.co/t/apm-java-agent-exception-at-startup/250208/11 "2020-10-07T07:36:09Z")

</div>

> [@gerardnorton](#):
>
> If I use a version greater than 4.5.1 for JNA the APM agent does not work, with the following error

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](https://github.com/raphw/byte-buddy/issues)

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [October 7, 2020, 7:36am UTC](https://discuss.elastic.co/t/apm-java-agent-exception-at-startup/250208/12 "2020-10-07T07:36:19Z")

</div>


