awspring / spring-cloud-aws

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

While using SQS application is failed to start #1167

Closed sabarees19 closed 4 months ago

sabarees19 commented 4 months ago

Type: Bug

Component: SQS

Describe the bug Actually while am trying in new separate demo project it's working fine. while am trying in main project where i used other services like s3,cognito,ses where they have used

aws.secretAccessKey=hcsahHJVGVbhwebhjbcwhjb+73478347 aws.accessKeyId=ASSJSJ67436734HJVG aws.region=ap-south-1

<dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>{service}</artifactId>
            <version>2.21.20</version>
 </dependency>

Sample

<dependency>
            <groupId>io.awspring.cloud</groupId>
            <artifactId>spring-cloud-aws-starter</artifactId>
            <version>3.1.1</version>
        </dependency>
        <dependency>
            <groupId>io.awspring.cloud</groupId>
            <artifactId>spring-cloud-aws-starter-sqs</artifactId>
            <version>3.1.1</version>
        </dependency>
        <dependency>
            <groupId>io.awspring.cloud</groupId>
            <artifactId>spring-cloud-aws-dependencies</artifactId>
            <version>3.1.1</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'listenerContainerFactory' defined in class path resource [com/demo/config/SQSConfiguration.class]: Failed to instantiate [io.awspring.cloud.sqs.config.SqsMessageListenerContainerFactory]: Factory method 'listenerContainerFactory' threw exception with message: Error creating bean with name 'sqsAsyncClient' defined in class path resource [com/demo/config/SQSConfiguration.class]: Failed to instantiate [software.amazon.awssdk.services.sqs.SqsAsyncClient]: Factory method 'sqsAsyncClient' threw exception with message: software/amazon/awssdk/utils/AttributeMap$LazyValue

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'listenerContainerFactory' defined in class path resource [com/demo/config/SQSConfiguration.class]: Failed to instantiate [io.awspring.cloud.sqs.config.SqsMessageListenerContainerFactory]: Factory method 'listenerContainerFactory' threw exception with message: Error creating bean with name 'sqsAsyncClient' defined in class path resource [com/demo/config/SQSConfiguration.class]: Failed to instantiate [software.amazon.awssdk.services.sqs.SqsAsyncClient]: Factory method 'sqsAsyncClient' threw exception with message: software/amazon/awssdk/utils/AttributeMap$LazyValue

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'listenerContainerFactory' defined in class path resource [com/demo/config/SQSConfiguration.class]: Failed to instantiate [io.awspring.cloud.sqs.config.SqsMessageListenerContainerFactory]: Factory method 'listenerContainerFactory' threw exception with message: Error creating bean with name 'sqsAsyncClient' defined in class path resource [com/demo/config/SQSConfiguration.class]: Failed to instantiate [software.amazon.awssdk.services.sqs.SqsAsyncClient]: Factory method 'sqsAsyncClient' threw exception with message: software/amazon/awssdk/utils/AttributeMap$LazyValue at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:648) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:485) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1335) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1165) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:975) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:962) ~[spring-context-6.1.5.jar:6.1.5] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:624) ~[spring-context-6.1.5.jar:6.1.5] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.2.4.jar:3.2.4] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-3.2.4.jar:3.2.4] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456) ~[spring-boot-3.2.4.jar:3.2.4] at org.springframework.boot.SpringApplication.run(SpringApplication.java:334) ~[spring-boot-3.2.4.jar:3.2.4] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354) ~[spring-boot-3.2.4.jar:3.2.4] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-3.2.4.jar:3.2.4] at com.demo.VeacyApplication.main(VeacyApplication.java:14) ~[classes/:na] at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50) ~[spring-boot-devtools-3.2.4.jar:3.2.4] Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.awspring.cloud.sqs.config.SqsMessageListenerContainerFactory]: Factory method 'listenerContainerFactory' threw exception with message: Error creating bean with name 'sqsAsyncClient' defined in class path resource [com/demo/config/SQSConfiguration.class]: Failed to instantiate [software.amazon.awssdk.services.sqs.SqsAsyncClient]: Factory method 'sqsAsyncClient' threw exception with message: software/amazon/awssdk/utils/AttributeMap$LazyValue at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:177) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:644) ~[spring-beans-6.1.5.jar:6.1.5] ... 22 common frames omitted Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqsAsyncClient' defined in class path resource [com/demo/config/SQSConfiguration.class]: Failed to instantiate [software.amazon.awssdk.services.sqs.SqsAsyncClient]: Factory method 'sqsAsyncClient' threw exception with message: software/amazon/awssdk/utils/AttributeMap$LazyValue at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:648) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:485) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1335) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1165) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.resolveBeanReference(ConfigurationClassEnhancer.java:362) ~[spring-context-6.1.5.jar:6.1.5] at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:334) ~[spring-context-6.1.5.jar:6.1.5] at com.demo.config.SQSConfiguration$$SpringCGLIB$$0.sqsAsyncClient() ~[classes/:na] at com.demo.config.SQSConfiguration.listenerContainerFactory(SQSConfiguration.java:36) ~[classes/:na] at com.demo.config.SQSConfiguration$$SpringCGLIB$$0.CGLIB$listenerContainerFactory$1() ~[classes/:na] at com.demo.config.SQSConfiguration$$SpringCGLIB$$FastClass$$1.invoke() ~[classes/:na] at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:258) ~[spring-core-6.1.5.jar:6.1.5] at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-6.1.5.jar:6.1.5] at com.demo.config.SQSConfiguration$$SpringCGLIB$$0.listenerContainerFactory() ~[classes/:na] at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:140) ~[spring-beans-6.1.5.jar:6.1.5] ... 23 common frames omitted Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [software.amazon.awssdk.services.sqs.SqsAsyncClient]: Factory method 'sqsAsyncClient' threw exception with message: software/amazon/awssdk/utils/AttributeMap$LazyValue at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:177) ~[spring-beans-6.1.5.jar:6.1.5] at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:644) ~[spring-beans-6.1.5.jar:6.1.5] ... 44 common frames omitted Caused by: java.lang.NoClassDefFoundError: software/amazon/awssdk/utils/AttributeMap$LazyValue at software.amazon.awssdk.services.sqs.DefaultSqsBaseClientBuilder.finalizeServiceConfiguration(DefaultSqsBaseClientBuilder.java:79) ~[sqs-2.21.46.jar:na] at software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder.finalizeChildConfiguration(AwsDefaultClientBuilder.java:185) ~[aws-core-2.21.20.jar:na] at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.asyncClientConfiguration(SdkDefaultClientBuilder.java:224) ~[sdk-core-2.21.20.jar:na] at software.amazon.awssdk.services.sqs.DefaultSqsAsyncClientBuilder.buildClient(DefaultSqsAsyncClientBuilder.java:37) ~[sqs-2.21.46.jar:na] at software.amazon.awssdk.services.sqs.DefaultSqsAsyncClientBuilder.buildClient(DefaultSqsAsyncClientBuilder.java:25) ~[sqs-2.21.46.jar:na] at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.build(SdkDefaultClientBuilder.java:157) ~[sdk-core-2.21.20.jar:na] at com.demo.config.SQSConfiguration.sqsAsyncClient(SQSConfiguration.java:47) ~[classes/:na] at com.demo.config.SQSConfiguration$$SpringCGLIB$$0.CGLIB$sqsAsyncClient$2() ~[classes/:na] at com.demo.config.SQSConfiguration$$SpringCGLIB$$FastClass$$1.invoke() ~[classes/:na] at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:258) ~[spring-core-6.1.5.jar:6.1.5] at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-6.1.5.jar:6.1.5] at com.demo.config.SQSConfiguration$$SpringCGLIB$$0.sqsAsyncClient() ~[classes/:na] at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:140) ~[spring-beans-6.1.5.jar:6.1.5] ... 45 common frames omitted Caused by: java.lang.ClassNotFoundException: software.amazon.awssdk.utils.AttributeMap$LazyValue 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:526) ~[na:na] ... 60 common frames omitted

sabarees19 commented 4 months ago

I have fixed the issue it is because the other dependencies are in low versions.

sabarees19 commented 4 months ago

Fixed the issue.