NoClassDefFoundError starting with Java agent version 1.23

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)

Hi and welcome to our forum!

It may be related to an issue fixed by https://github.com/elastic/apm-agent-java/pull/1785.
In order to test that, please try our latest build from master.

If this doesn't solve the issue, please set log_level to debug and provide a full agent log from startup and including the full stack trace.

Hi Eyal,

It seems the fix does fix the issue - at least it doesn't occur with the snapshot anymore.

Thanks a lot! Is there already a timeline for releasing 1.23.1?

Awesome!
We don't have a rigid timeline for releases, but you can register on our repo to receive notifications about releases.
In the mean time, you can either use 1.22.0, or keep using this snapshot (note that we also release from master so it should be OK in terms of stability).