APM Java Agent crashes with Springboot 2

The same project runs with APM 1.8 Javaclient but with 1.9.0 the JVM crashes without any information from program

pom.xml

       <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.1.7.RELEASE</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.example</groupId>
	<artifactId>demo</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>demo</name>
	<description>Demo project for Spring Boot</description>

	<properties>
		<version.elastic.apm>1.9.0</version.elastic.apm>
		<java.version>1.8</java.version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>co.elastic.apm</groupId>
			<artifactId>apm-agent-attach</artifactId>
			<version>${version.elastic.apm}</version>
		</dependency>
		<dependency>
			<groupId>co.elastic.apm</groupId>
			<artifactId>apm-agent-api</artifactId>
			<version>${version.elastic.apm}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
			<exclusions>
				<exclusion>
					<groupId>org.springframework.boot</groupId>
					<artifactId>spring-boot-starter-logging</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

</project>

Starter class

    public static void main(String[] args) {
Map<String, String> options = new HashMap<>();
options.put("service_name", simulation");
options.put("application_packages", "eu.amova,com.siemag,pas.core");
options.put("elastic.apm.stack_trace_limit", "0");
options.put("elastic.apm.span_frames_min_duration", "0ms");
options.put("disable_instrumentations", "elasticsearch-restclient,concurrent,executor,jax-rs,jax-ws,jdbc,scheduled");
options.put("server_urls", apm_server_urls);
ElasticApmAttacher.attach(options);
SpringApplication.run(DemoApplication.class, args);
}

I'm sorry to hear that. On which Java version, vendor and OS does that happen?

java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

With Windows 10 host

But it is the same with OpenJDK 12.0.1 and langugage level 12

Any crash reports from the JVM? Look out for hs_err_pid<pid>.log in the current directory.

nope :rage:

but you should easily reproduce it.
Create a project from springinitzlr site and add apm agent version 1.9 :wink:

Did you make any progress on this issue ?

Sorry for the radio silence. I was on vacation last week. I'll try to reproduce at home where I have a Win 10 desktop PC. My inbox is kinda exploding but I'll try to investigate this asap.

1 Like

Did you try run this on ubuntu?
On ubuntu application started success:

nindzya@pc:/opt/nindzya$ java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

Pitty that's not a solution for me.

The company have a Microsoft infrastructure :rage:

I could finally reproduce it. It's currently a restriction of the emulated attach on Windows (see also https://github.com/raphw/byte-buddy/issues/723). It crashes the VM if the agent arguments are too long.

A workaround for this is to use system properties for the configuration:

public static void main(String[] args) {
    System.setProperty("elastic.apm.service_name", "simulation");
    System.setProperty("elastic.apm.application_packages", "eu.amova,com.siemag,pas.core");
    System.setProperty("elastic.apm.stack_trace_limit", "0");
    System.setProperty("elastic.apm.span_frames_min_duration", "0ms");
    System.setProperty("elastic.apm.disable_instrumentations", "elasticsearch-restclient,concurrent,executor,jax-rs,jax-ws,jdbc,scheduled");
    System.setProperty("elastic.apm.server_urls", apm_server_urls);
    ElasticApmAttacher.attach();
    SpringApplication.run(DemoApplication.class, args);
}
1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.