awspring / spring-cloud-aws

The New Home for Spring Cloud AWS
http://awspring.io
Apache License 2.0
825 stars 283 forks source link

Version 3.1.1 looks for old @SqsListener #1170

Open armorcodehemant opened 5 days ago

armorcodehemant commented 5 days ago

Type: Bug

Component: "SQS"

Describe the bug after upgrading to spring spring-cloud-aws-sqs and spring-cloud-aws-starter-sqs 3.1.1 and sqs 2.23.0 when starting the application I am getting, I am using spring boot 3.2.2

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'io.awspring.cloud.messaging.internalSqsListenerAnnotationBeanPostProcessor': BeanPostProcessor before instantiation of bean failed at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:325) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:323) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204) at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:277) at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:805) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:608) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456) at org.springframework.boot.SpringApplication.run(SpringApplication.java:334) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) at com.armorcode.authserver.BackgroundJobsApplication.main(BackgroundJobsApplication.java:46) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cache.annotation.ProxyCachingConfiguration': BeanPostProcessor before instantiation of bean faile ... Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': error Type referred to is not an annotation type: org$springframework$cloud$aws$messaging$listener$annotation$SqsListener ... Caused by: java.lang.IllegalArgumentException: error Type referred to is not an annotation type: org$springframework$cloud$aws$messaging$listener$annotation$SqsListener ...

Sample `@Autowired private SqsProperties sqsProperties;

@Bean @Primary @ConditionalOnMissingBean(SqsAsyncClient.class) public SqsAsyncClient amazonSQSAsync() {

AwsCredentialsProvider credentialsProvider = null;
if (sqsProperties.isIamEnabled()) {
    credentialsProvider = InstanceProfileCredentialsProvider.create();
} else {
    credentialsProvider = StaticCredentialsProvider.create(
            AwsBasicCredentials.create(
                    sqsProperties.getUserId(),
                    sqsProperties.getUserKey()));
}

Region region = Region.of(Optional.ofNullable(sqsProperties.getRegionName()).orElse(Region.US_EAST_2.id()));
SqsAsyncClientBuilder SqsAsyncClientBuilder = SqsAsyncClient.builder();

SdkAsyncHttpClient httpClient = NettyNioAsyncHttpClient.builder()
        .maxConcurrency(200)
        .build();

return SqsAsyncClientBuilder
        .credentialsProvider(credentialsProvider)
        .httpClient(httpClient)
        .region(region)
        .build();

} @Bean SqsListenerConfigurer configurer(ObjectMapper objectMapper) { return registrar -> registrar.setObjectMapper(objectMapper); }

@Bean public SqsMessageListenerContainerFactory defaultSqsListenerContainerFactory() { return SqsMessageListenerContainerFactory .builder() .sqsAsyncClient(amazonSQSAsync()) .build(); }`

armorcodehemant commented 5 days ago

Spring dependencies i have [INFO] | +- org.springframework:spring-jdbc:jar:6.1.3:compile [INFO] | | +- org.springframework:spring-beans:jar:6.1.3:compile [INFO] | | - org.springframework:spring-tx:jar:6.1.3:compile [INFO] +- org.springframework.boot:spring-boot-starter-web:jar:3.2.2:compile [INFO] | +- org.springframework.boot:spring-boot-starter:jar:3.2.2:compile [INFO] | | - org.springframework.boot:spring-boot:jar:3.2.2:compile [INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:3.2.2:compile [INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:3.2.2:compile [INFO] | +- org.springframework:spring-web:jar:6.1.3:compile [INFO] | - org.springframework:spring-webmvc:jar:6.1.3:compile [INFO] | +- org.springframework:spring-aop:jar:6.1.3:compile [INFO] | +- org.springframework:spring-context:jar:6.1.3:compile [INFO] | - org.springframework:spring-expression:jar:6.1.3:compile [INFO] | +- org.springframework.boot:spring-boot-starter-data-jpa:jar:3.2.2:compile [INFO] | | +- org.springframework.boot:spring-boot-starter-aop:jar:3.2.2:compile [INFO] | | +- org.springframework.boot:spring-boot-starter-jdbc:jar:3.2.2:compile [INFO] | | | - org.springframework.boot:spring-boot-autoconfigure:jar:3.2.2:compile [INFO] | | - org.springframework.data:spring-data-jpa:jar:3.2.2:compile [INFO] | | - org.springframework:spring-orm:jar:6.1.3:compile [INFO] | +- org.springframework.boot:spring-boot-starter-data-mongodb:jar:3.2.2:compile [INFO] | | - org.springframework.data:spring-data-mongodb:jar:4.2.2:compile [INFO] | +- org.springframework.boot:spring-boot-configuration-processor:jar:3.2.2:compile [INFO] | +- org.springframework.data:spring-data-elasticsearch:jar:4.2.9:compile [INFO] | +- org.springframework:spring-aspects:jar:6.1.3:compile [INFO] | - org.aspectj:aspectjweaver:jar:1.9.21:compile [INFO] | +- org.springframework.boot:spring-boot-starter-log4j2:jar:3.2.2:compile [INFO] | +- org.springframework.boot:spring-boot-starter-validation:jar:3.2.2:compile [INFO] | +- org.springframework.boot:spring-boot-starter-log4j2:jar:3.2.2:compile [INFO] | +- org.springframework:spring-messaging:jar:6.1.3:compile [INFO] | +- org.springframework.session:spring-session-data-redis:jar:3.2.1:compile [INFO] | | - org.springframework.session:spring-session-core:jar:3.2.1:compile [INFO] | +- org.springframework.boot:spring-boot-starter-actuator:jar:3.2.2:compile [INFO] | | - org.springframework.boot:spring-boot-actuator:jar:3.2.2:compile [INFO] | | - org.springframework.boot:spring-boot-actuator-autoconfigure:jar:3.2.2:compile [INFO] | +- org.springframework:spring-core:jar:6.1.3:compile [INFO] | | - org.springframework:spring-jcl:jar:6.1.3:compile [INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:3.2.2:test [INFO] | | - org.springframework.boot:spring-boot-test:jar:3.2.2:test [INFO] | - org.springframework:spring-test:jar:6.1.3:test [INFO] +- org.springframework.kafka:spring-kafka:jar:3.1.1:compile [INFO] +- org.springframework.boot:spring-boot-starter-quartz:jar:3.2.2:compile [INFO] +- org.springframework.security:spring-security-web:jar:6.2.3:compile [INFO] | - org.springframework.security:spring-security-core:jar:6.2.3:compile [INFO] | - org.springframework.security:spring-security-crypto:jar:6.2.3:compile [INFO] | +- org.springframework.security:spring-security-oauth2-jose:jar:6.2.3:compile [INFO] | | - org.springframework.security:spring-security-oauth2-core:jar:6.2.3:compile [INFO] | +- org.springframework.data:spring-data-commons:jar:3.2.2:compile [INFO] | - org.springframework.security:spring-security-oauth2-core:jar:6.2.3:compile [INFO] +- io.awspring.cloud:spring-cloud-aws-starter-ses:jar:3.1.1:compile [INFO] +- io.awspring.cloud:spring-cloud-aws-starter:jar:3.1.1:compile [INFO] +- io.awspring.cloud:spring-cloud-aws-autoconfigure:jar:3.1.1:compile [INFO] +- io.awspring.cloud:spring-cloud-aws-core:jar:3.1.1:compile [INFO] +- io.awspring.cloud:spring-cloud-aws-starter-secrets-manager:jar:3.1.1:compile [INFO] +- io.awspring.cloud:spring-cloud-aws-secrets-manager:jar:3.1.1:compile [INFO] +- io.awspring.cloud:spring-cloud-aws-sqs:jar:3.1.1:compile [INFO] +- io.awspring.cloud:spring-cloud-aws-s3:jar:3.1.1:compile