APM Java Agent 1.40 leads to NoClassDefFoundError (ReceiveMessageRequest) in S3 communication with AWS Java SDK v2

APM Agent language and version: Java 1.40.0

Description of the problem including expected versus actual behavior. Please include screenshots (if relevant):

We recently updated the APM Java Agent in our Spring Boot service from 1.39.0 to 1.40.0.
The service uses the AWS Java SDK v2 via Spring Cloud AWS 3.0.1, more specifically the "spring-cloud-aws-starter-s3" artifact of "io.awspring.cloud".

Since that update to 1.40.0 the log of our service has frequent occurrences of

ERROR co.elastic.apm.agent.bci.IndyBootstrap - Advice threw an exception, this should never happen!
java.lang.NoClassDefFoundError: software/amazon/awssdk/services/sqs/model/ReceiveMessageRequest

The full log extract is

2023-07-25 08:48:01,379 [https-jsse-nio-8443-exec-2] ERROR co.elastic.apm.agent.bci.IndyBootstrap - Advice threw an exception, this should never happen!
java.lang.NoClassDefFoundError: software/amazon/awssdk/services/sqs/model/ReceiveMessageRequest
	at co.elastic.apm.agent.awssdk.v2.helper.SQSHelper.modifyRequestObject(SQSHelper.java:127) ~[elastic-apm-agent-40510175845988f13f6162ed8526f0b0-7dd1ac9d05061b60f522858625c85e5a.jar:1.40.0]
	at co.elastic.apm.agent.awssdk.v2.BaseSyncClientHandlerInstrumentation$AdviceClass.enterDoExecute(BaseSyncClientHandlerInstrumentation.java:105) ~[elastic-apm-agent-40510175845988f13f6162ed8526f0b0-7dd1ac9d05061b60f522858625c85e5a.jar:1.40.0]
	at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.doExecute(BaseSyncClientHandler.java:149) ~[sdk-core-2.20.63.jar!/:?]
	at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.lambda$execute$1(BaseSyncClientHandler.java:82) ~[sdk-core-2.20.63.jar!/:?]
	at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.measureApiCallSuccess(BaseSyncClientHandler.java:179) ~[sdk-core-2.20.63.jar!/:?]
	at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:76) ~[sdk-core-2.20.63.jar!/:?]
	at software.amazon.awssdk.core.client.handler.SdkSyncClientHandler.execute(SdkSyncClientHandler.java:45) ~[sdk-core-2.20.63.jar!/:?]
	at software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler.execute(AwsSyncClientHandler.java:56) ~[aws-core-2.20.63.jar!/:?]
	at software.amazon.awssdk.services.s3.DefaultS3Client.listObjectsV2(DefaultS3Client.java:6538) ~[s3-2.20.63.jar!/:?]
	at software.amazon.awssdk.services.s3.paginators.ListObjectsV2Iterable$ListObjectsV2ResponseFetcher.nextPage(ListObjectsV2Iterable.java:153) ~[s3-2.20.63.jar!/:?]
	at software.amazon.awssdk.services.s3.paginators.ListObjectsV2Iterable$ListObjectsV2ResponseFetcher.nextPage(ListObjectsV2Iterable.java:144) ~[s3-2.20.63.jar!/:?]
	at software.amazon.awssdk.core.pagination.sync.PaginatedResponsesIterator.next(PaginatedResponsesIterator.java:58) ~[sdk-core-2.20.63.jar!/:?]
	at java.util.Iterator.forEachRemaining(Iterator.java:133) ~[?:?]
	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845) ~[?:?]
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?]
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) ~[?:?]
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) ~[?:?]
	at io.awspring.cloud.s3.S3PathMatchingResourcePatternResolver.findResourcesInBucketWithKeyPattern(S3PathMatchingResourcePatternResolver.java:210) ~[spring-cloud-aws-s3-3.0.1.jar!/:3.0.1]
	at io.awspring.cloud.s3.S3PathMatchingResourcePatternResolver.lambda$findResourcesInBucketsWithPatterns$0(S3PathMatchingResourcePatternResolver.java:184) ~[spring-cloud-aws-s3-3.0.1.jar!/:3.0.1]
	at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:273) [?:?]
	at java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(AbstractList.java:720) [?:?]
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) [?:?]
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) [?:?]
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575) [?:?]
	at java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260) [?:?]
	at java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616) [?:?]
	at io.awspring.cloud.s3.S3PathMatchingResourcePatternResolver.findResourcesInBucketsWithPatterns(S3PathMatchingResourcePatternResolver.java:185) [spring-cloud-aws-s3-3.0.1.jar!/:3.0.1]
	at io.awspring.cloud.s3.S3PathMatchingResourcePatternResolver.getResources(S3PathMatchingResourcePatternResolver.java:137) [spring-cloud-aws-s3-3.0.1.jar!/:3.0.1]
	at de.otto.sgstartservice.news.service.NewsService.listAllNews(NewsService.java:80) [classes!/:0.0.1-SNAPSHOT]
	at de.otto.sgstartservice.news.service.NewsService.findNews(NewsService.java:49) [classes!/:0.0.1-SNAPSHOT]
	at de.otto.sgstartservice.news.controller.NewsController.readAll(NewsController.java:27) [classes!/:0.0.1-SNAPSHOT]
	at jdk.internal.reflect.GeneratedMethodAccessor61.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) [spring-web-5.3.28.jar!/:5.3.28]
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) [spring-web-5.3.28.jar!/:5.3.28]
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) [spring-webmvc-5.3.28.jar!/:5.3.28]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) [spring-webmvc-5.3.28.jar!/:5.3.28]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) [spring-webmvc-5.3.28.jar!/:5.3.28]
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) [spring-webmvc-5.3.28.jar!/:5.3.28]
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1072) [spring-webmvc-5.3.28.jar!/:5.3.28]
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:965) [spring-webmvc-5.3.28.jar!/:5.3.28]
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) [spring-webmvc-5.3.28.jar!/:5.3.28]
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) [spring-webmvc-5.3.28.jar!/:5.3.28]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:529) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) [spring-webmvc-5.3.28.jar!/:5.3.28]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:623) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:209) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) [tomcat-embed-websocket-9.0.76.jar!/:?]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:337) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:81) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:122) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:116) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:126) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:81) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:109) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) [spring-security-web-5.7.9.jar!/:5.7.9]
	at de.otto.sgoscauthentication.user.OscAuthenticationFilter.successfulAuthentication(OscAuthenticationFilter.java:59) [sg-osc-authentication-2.7.5.123.jar!/:2.7.5.123]
	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:237) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:217) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:149) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilterInternal(BasicAuthenticationFilter.java:164) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) [spring-web-5.3.28.jar!/:5.3.28]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:117) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) [spring-web-5.3.28.jar!/:5.3.28]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) [spring-web-5.3.28.jar!/:5.3.28]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:112) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:82) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) [spring-web-5.3.28.jar!/:5.3.28]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.session.DisableEncodeUrlFilter.doFilterInternal(DisableEncodeUrlFilter.java:42) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) [spring-web-5.3.28.jar!/:5.3.28]
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:221) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:186) [spring-security-web-5.7.9.jar!/:5.7.9]
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:354) [spring-web-5.3.28.jar!/:5.3.28]
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:267) [spring-web-5.3.28.jar!/:5.3.28]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) [spring-web-5.3.28.jar!/:5.3.28]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) [spring-web-5.3.28.jar!/:5.3.28]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) [spring-web-5.3.28.jar!/:5.3.28]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) [spring-web-5.3.28.jar!/:5.3.28]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:96) [spring-boot-actuator-2.7.13.jar!/:2.7.13]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) [spring-web-5.3.28.jar!/:5.3.28]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) [spring-web-5.3.28.jar!/:5.3.28]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) [spring-web-5.3.28.jar!/:5.3.28]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:481) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:130) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:390) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:926) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1791) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) [tomcat-embed-core-9.0.76.jar!/:?]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.76.jar!/:?]
	at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.ClassNotFoundException: software.amazon.awssdk.services.sqs.model.ReceiveMessageRequest
	... 131 more

What struck me as odd is the occurrence of co.elastic.apm.agent.awssdk.v2.helper.SQSHelper.modifyRequestObject as our service doesn't use SQS but only S3. Therefore we do not use a maven dependency for SQS (spring-cloud-aws-starter-sqs) which explains why software/amazon/awssdk/services/sqs/model/ReceiveMessageRequest cannot be found.

I think this refactoring broke our case: Context propagation refactorings (#3206) · elastic/apm-agent-java@86184c5 · GitHub

This commit moved the usage of the SQSHelper class outside the if/else block that distinguishes between the actual AWS service. Which seems wrong to me at first glance.

Could the instrumentation be changed so that it works again without the SQS dependency if the applications doesn't use SQS (which wasn't required in 1.39.0), i.e. not producing any error logs if the dependency is not present?

Steps to reproduce:

  1. Use APM Java Agent 1.40.0 in a service that only communicates with AWS S3 but not AWS SQS and therefore doesn't include dependencies to the SQS classes of the AWS Java SDK

Edit 2024-05-16: somehow this topic got flagged as spam?!? Editing it to unhide it...

1 Like

Thanks for the detailed bug report and root cause analysis!
I've create a PR to fix the bug, could you maybe try out the agent snapshot and verify that it actually fixes it?

Hey Jonas,

that was really quick, thank you :slight_smile:

I was able to test your snapshot and the exception is gone.

Looks good to me!

Thanks again.

I'm still seeing the same exception even with

"co.elastic.apm" % "elastic-apm-agent" % "1.41.0"

java.lang.NoClassDefFoundError: software/amazon/awssdk/services/sqs/model/ReceiveMessageRequest
	at co.elastic.apm.agent.awssdk.v2.helper.SQSHelper.modifyRequestObject(SQSHelper.java:127)
	at co.elastic.apm.agent.awssdk.v2.BaseAsyncClientHandlerInstrumentation$AdviceClass.enterDoExecute(BaseAsyncClientHandlerInstrumentation.java:95)
	at software.amazon.awssdk.core.internal.handler.BaseAsyncClientHandler.doExecute(BaseAsyncClientHandler.java:197)
	at software.amazon.awssdk.core.internal.handler.BaseAsyncClientHandler.lambda$execute$1(BaseAsyncClientHandler.java:82)
	at software.amazon.awssdk.core.internal.handler.BaseAsyncClientHandler.measureApiCallSuccess(BaseAsyncClientHandler.java:291)
	at software.amazon.awssdk.core.internal.handler.BaseAsyncClientHandler.execute(BaseAsyncClientHandler.java:75)
	at software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler.execute(AwsAsyncClientHandler.java:52)
	at software.amazon.awssdk.services.s3.DefaultS3AsyncClient.listObjects(DefaultS3AsyncClient.java:7038)

i'm also using only s3

It seems the handling in BaseAsyncClientHandlerInstrumentation is a bit different compared to "my" sync client instrumentation.

It calls the SQSHelper in a try/finally outside the if/else clause for the type of service, but with not catch.
Looks like it has to get fixed there, too.

Having same issue on 1.41.0

Looks indeed like I missed out on the code path for the async client with the fix.
Could you try this snapshot and report back whether it fixes the issue for you?

We'll put out a patch-release ASAP.

Hi, I could not find ElasticApmAttacher in this snapshot jar

Here is the corresponding attacher-artifact.

1 Like

Yes!! I have tried with the snapshot you mentioned, there were no error log. I think the problem is solved.

Thank you so much. Can I ask when will be the next release for this fix?

We'll try to do a release at the start of next week.

1 Like

Thank you for quick response

We just released 1.41.1, which includes the fix for the async client.

1 Like

We have already started to use. :slight_smile:

Thanks for support

I am the one who likes first and only :slight_smile:

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