Apm agent failed to start on open JDK 11

APM Server version:
7.3.1

APM Agent language and version:
java 11 - elastic-apm-agent: 1.9.0

Original install method (e.g. download page, yum, deb, from source, etc.) and version:
docker 7.3.1
Fresh install or upgraded from other version?
docker 7.3.1
Description of the problem including expected versus actual behavior. Please include screenshots (if relevant):
Apm agent failed to start on open JDK 11

Steps to reproduce:

  1. create a basic helloworld project
  2. Launch this project using openJdk 11 and the apm agent 1.9.0:
    java
    -javaagent:agents/elastic-apm-agent-1.9.0.jar
    -Delastic.apm.server_url=http://localhost:8200
    -Delastic.apm.service_name=test
    -Delastic.apm.application_packages=test
    -jar helloworld.jar

Provide logs and/or server output (if relevant):

OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
2019-09-02 16:07:16.723 [apm-server-healthcheck] INFO co.elastic.apm.agent.report.ApmServerHealthChecker - Elastic APM server is available: {  "build_date": "2019-08-19T19:05:40Z",  "build_sha": "ead4e8ba325a393bf1a83d0d0a4130114b5f778e",  "version": "7.3.1"}
Failed to start agent
java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at co.elastic.apm.agent.bci.AgentMain.init(AgentMain.java:85)
	at co.elastic.apm.agent.bci.AgentMain.premain(AgentMain.java:54)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:513)
	at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:525)
Caused by: java.lang.NoClassDefFoundError: sun/misc/Unsafe
	at co.elastic.apm.agent.shaded.lmax.disruptor.util.Util$1.run(Util.java:103)
	at co.elastic.apm.agent.shaded.lmax.disruptor.util.Util$1.run(Util.java:100)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at co.elastic.apm.agent.shaded.lmax.disruptor.util.Util.<clinit>(Util.java:109)
	at co.elastic.apm.agent.shaded.lmax.disruptor.RingBufferFields.<clinit>(RingBuffer.java:34)
	at co.elastic.apm.agent.shaded.lmax.disruptor.dsl.Disruptor.<init>(Disruptor.java:137)
	at co.elastic.apm.agent.report.ApmServerReporter.<init>(ApmServerReporter.java:106)
	at co.elastic.apm.agent.report.ReporterFactory.createReporter(ReporterFactory.java:43)
	at co.elastic.apm.agent.impl.ElasticApmTracerBuilder.build(ElasticApmTracerBuilder.java:117)
	at co.elastic.apm.agent.bci.ElasticApmAgent.initialize(ElasticApmAgent.java:98)
	... 12 more
hello

Hi,

Can you check if version 1.8.0 of the agent would work?

We are using the java agent 1.8.0 on the Amazon Corretto JDK 11.0.4 (on RedHat 6) and it works for us.

If this works for you someone has to find out why the the new version does not work.

Best regards
Wolfram

1 Like

Hi,

same issue with the 1.8.0
java -version gives me:

openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3)
OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3, mixed mode, sharing)

for the OS:

Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic

regards

The only difference I can see here is that we still use APM Server 6.8 so maybe the connection logic for 6.x and 7.x are different? Maybe someone from the team can have a look at it?

in fact I was doing my tests inside eclipse,
I have redone my test using the command line and I am not facing anymore the issue.

regards