Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CloudWatchAsyncClient: Class not found software.amazon.awssdk.protocols.query.interceptor.QueryParametersToBodyInterceptor #4791

Closed
pawelryznar opened this issue Dec 18, 2023 · 4 comments
Assignees
Labels
guidance Question that needs advice or information.

Comments

@pawelryznar
Copy link

pawelryznar commented Dec 18, 2023

Describe the bug

After upgrading AWS SDK from 2.20.83 to 2.22.0 my application is failing, because CloudWatchAsyncClient bean cannot be created because of the following error:


Caused by: java.lang.ClassNotFoundException: software.amazon.awssdk.protocols.query.interceptor.QueryParametersToBodyInterceptor
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)

Expected Behavior

CloudWatchAsyncClient should not be failing

Current Behavior

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [software.amazon.awssdk.services.cloudwatch.CloudWatchAsyncClient]: Factory method 'cloudWatchAsyncClient' threw exception with message: software/amazon/awssdk/protocols/query/interceptor/QueryParametersToBodyInterceptor
	at app//org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:178)
	at app//org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651)
	... 123 more
Caused by: java.lang.NoClassDefFoundError: software/amazon/awssdk/protocols/query/interceptor/QueryParametersToBodyInterceptor
	at software.amazon.awssdk.services.cloudwatch.DefaultCloudWatchBaseClientBuilder.finalizeServiceConfiguration(DefaultCloudWatchBaseClientBuilder.java:74)
	at software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder.finalizeChildConfiguration(AwsDefaultClientBuilder.java:160)
	at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.asyncClientConfiguration(SdkDefaultClientBuilder.java:219)
	at software.amazon.awssdk.services.cloudwatch.DefaultCloudWatchAsyncClientBuilder.buildClient(DefaultCloudWatchAsyncClientBuilder.java:39)
	at software.amazon.awssdk.services.cloudwatch.DefaultCloudWatchAsyncClientBuilder.buildClient(DefaultCloudWatchAsyncClientBuilder.java:26)
	at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.build(SdkDefaultClientBuilder.java:155)
	at com.myapp.configuration.CloudWatchConfiguration.cloudWatchAsyncClient(CloudWatchConfiguration.java:35)
	at com.myapp.configuration.CloudWatchConfiguration$$SpringCGLIB$$0.CGLIB$cloudWatchAsyncClient$0(<generated>)
	at com.myapp.configuration.CloudWatchConfiguration$$SpringCGLIB$$FastClass$$1.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:258)
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
	at com.myapp.configuration.CloudWatchConfiguration$$SpringCGLIB$$0.cloudWatchAsyncClient(<generated>)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:140)
	... 124 more
Caused by: java.lang.ClassNotFoundException: software.amazon.awssdk.protocols.query.interceptor.QueryParametersToBodyInterceptor
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
	... 139 more

Reproduction Steps

In my project I'm using Spring Boot 3.2, Java 21 and following aws libs
implementation("software.amazon.awssdk:sts:2.22.0")
implementation("software.amazon.awssdk:netty-nio-client:2.22.0")

Following code is failing

import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.cloudwatch.CloudWatchAsyncClient;
import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient;

  @Bean
  CloudWatchAsyncClient cloudWatchAsyncClient() {
    var credentialsProvider = DefaultCredentialsProvider.create();
    return CloudWatchAsyncClient.builder()
       // .overrideConfiguration(AwsClientConfigurer.configureRetryPolicy()) // not required to reproduce
        .httpClientBuilder(nettyNioAsyncHttpClientBuilder())
        .region(Region.EU_CENTRAL_1)
        .credentialsProvider(credentialsProvider)
        .build();
  }

  public static NettyNioAsyncHttpClient.Builder nettyNioAsyncHttpClientBuilder() {
    return NettyNioAsyncHttpClient.builder()
        .maxConcurrency(Integer.MAX_VALUE)
        .connectionMaxIdleTime(Duration.ofMinutes(1))
        .connectionTimeToLive(Duration.ofHours(1));
  }

Possible Solution

software/amazon/awssdk/services/cloudwatch/DefaultCloudWatchBaseClientBuilder.java
should not use non existing class software.amazon.awssdk.protocols.query.interceptor.QueryParametersToBodyInterceptor

Additional Information/Context

No response

AWS Java SDK version used

2.22.0

JDK version used

openjdk 21.0.1 2023-10-17 LTS

Operating System and version

MacOS 14.1.2

@pawelryznar pawelryznar added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 18, 2023
@debora-ito
Copy link
Member

@pawelryznar this is likely caused by mismatched versions of SDK modules in your classpath. Make sure all modules are in the exact same version. You can check the versions of your dependency tree by running
$ gradle -q dependencies

@debora-ito debora-ito added closing-soon This issue will close in 4 days unless further comments are made. and removed needs-triage This issue or PR still needs to be triaged. labels Dec 18, 2023
@debora-ito debora-ito self-assigned this Dec 18, 2023
@pawelryznar
Copy link
Author

I see. Forgot to check that. Problem is https://mvnrepository.com/artifact/software.amazon.kinesis/amazon-kinesis-client/2.5.4 Which is still using SDK 2.20.43

@github-actions github-actions bot removed the closing-soon This issue will close in 4 days unless further comments are made. label Dec 19, 2023
@debora-ito debora-ito added guidance Question that needs advice or information. and removed bug This issue is a bug. labels Dec 19, 2023
@debora-ito
Copy link
Member

Glad you figured that out. Closing this.

Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

2 participants