APM Agent language and version: Java Agent v1.23
**Description of the problem including expected versus actual behavior. **:
We have a Spring Boot application in which we attach the Java APM Agent programmatically:
@SpringBootApplication
public class Server implements CommandLineRunner {
public static void main(final String... args) {
ElasticApmAttacher.attach();
SpringApplication.run(Server.class, args);
}
}
This application accesses AWS services' Rest APIs via the AWS Java SDK.
The application is built using Gradle and can be executed locally (on developer's machine) using ./gradlew -Dspring.profiles.active=local bootRun
while on AWS the application is actually deployed as a AWS Fargate task.
dependencies {
...
implementation "co.elastic.apm:apm-agent-attach:1.23.0"
...
}
While everything seems to work in the cloud environments we are facing following NoClassDefFoundError
for org/apache/http/HttpRequest
starting with agent version 1.23 in local environment while with 1.22 these entries are not appearing.
The class is actually available on the application's runtime classpath (according to ./gradlew htmlDependencyReport
) in org.apache.httpcomponents:httpcore:4.4.14
resp. httpcore-4.4.14.jar
as transitive dependency of software.amazon.awssdk:apache-client:2.16.44
resp. software.amazon.awssdk:sns:2.16.44
.
Any help/ directions would be appreciated.
Provide logs and/or server output:
java.lang.NoClassDefFoundError: org/apache/http/HttpRequest
at co.elastic.apm.agent.httpclient.helper.RequestHeaderAccessor.getFirstHeader(RequestHeaderAccessor.java:34)
at co.elastic.apm.agent.impl.transaction.TraceContext.containsTraceContextTextHeaders(TraceContext.java:195)
at co.elastic.apm.agent.httpclient.ApacheHttpClientInstrumentation$ApacheHttpClientAdvice.onBeforeExecute(ApacheHttpClientInstrumentation.java:71)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:155)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at software.amazon.awssdk.http.apache.internal.impl.ApacheSdkHttpClient.execute(ApacheSdkHttpClient.java:72)