Stack Exchange
Spring Boot 3.0.0, SQS: java.lang.ClassNotFoundException: org.springframework.messaging.handler.annotation.support.PayloadArgumentResolver
I am trying to setup @SqsListener working but I'm gettin this exception:
 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'simpleMessageListenerContainer' defined in org.springframework.cloud.aws.messaging.config.annotation.SqsConfiguration: Failed to instantiate [org.springframework.cloud.aws.messaging.listener.SimpleMessageListenerContainer]: Factory method 'simpleMessageListenerContainer' threw exception with message: Error creating bean with name 'queueMessageHandler' defined in org.springframework.cloud.aws.messaging.config.annotation.SqsConfiguration: org/springframework/messaging/handler/annotation/support/PayloadArgumentResolver
........
........
    Caused by: java.lang.ClassNotFoundException: org.springframework.messaging.handler.annotation.support.PayloadArgumentResolver
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[na:na]
        ... 44 common frames omitted

From my build.gradle:
dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
    implementation 'org.springframework.cloud:spring-cloud-aws-messaging:2.2.6.RELEASE'
    implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
    implementation 'org.springframework:spring-messaging:6.0.2'

    implementation 'io.awspring.cloud:spring-cloud-starter-aws-messaging:2.4.2'
    implementation 'io.awspring.cloud:spring-cloud-aws-dependencies:2.4.2'
    implementation 'software.amazon.awssdk:sqs:2.18.38'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

I tried different project setups but it all ending with: Caused by: java.lang.ClassNotFoundException: org.springframework.messaging.handler.annotation.support.PayloadArgumentResolver
I think PayloadArgumentResolver was deprecated as of Spring 5.2 in favor of PayloadMethodArgumentResolver.
Is it a bug or a dependencies issue?

Have you found a fix for this? I am running into the same issue.

The new version https://mvnrepository.com/artifact/io.awspring.cloud/spring-cloud-aws-starter-sqs/3.1.1 won't require hte PayloadMethodArgumentResolver.

Try downgrade the spring-messaging to version 5.3.24 as a workaround
implementation 'org.springframework:spring-messaging:5.3.24'


This worked for me, I actually didn't have this dependency on either version, but adding it helped. Thanks kekhuay

This worked for me. I am using Java 17 and springboot 3.2.2. Thanks.

Version 2.x of Spring Cloud AWS does not support Spring Boot 3. Have a look here https://github.com/awspring/spring-cloud-aws. Spring Boot 3 is supported from version 3.x of Spring Cloud AWS, which is at the moment at RC2 stage.

I also got the same issue and i updatd to awspring but i'm getting this error
Caused by: java.lang.ClassNotFoundException: io.awspring.cloud.core.env.ResourceIdResolver
Any help?

I don't use ResourceIdResolver, so could not advice here

Yeah, in my case I had to use PayloadMethodArgumentResolver and it worked.
 implementation('io.awspring.cloud:spring-cloud-aws-core:3.0.2') 
 implementation('io.awspring.cloud:spring-cloud-aws-messaging:2.4.4') 
 implementation('io.awspring.cloud:spring-cloud-starter-aws:2.4.4')


 @Bean  public QueueMessageHandler queueMessageHandler () {
        QueueMessageHandlerFactory queueMsgHandlerFactory = new
 QueueMessageHandlerFactory();
        queueMsgHandlerFactory.setAmazonSqs(amazonSQSAsync());
        QueueMessageHandler queueMessageHandler =
 queueMsgHandlerFactory.createQueueMessageHandler();
        List<HandlerMethodArgumentResolver> list = new ArrayList<>();
        HandlerMethodArgumentResolver resolver = new
 PayloadMethodArgumentResolver(new MappingJackson2MessageConverter());
        list.add(resolver);
        queueMessageHandler.setArgumentResolvers(list);
 
        return queueMessageHandler;     }

