Hi,

Because of the https://pivotal.io/security/cve-2018-11087 , we upgraded to spring-rabbit 2.0.8.RELEASE and the tests started failing with error :

java.lang.IllegalStateException: Failed to load ApplicationContext Caused by: java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration$MessagingTemplateConfiguration.rabbitMessagingTemplate Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration$RabbitTemplateConfiguration] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2] Caused by: java.lang.NoClassDefFoundError: org/springframework/retry/RetryPolicy Caused by: java.lang.ClassNotFoundException: org.springframework.retry.RetryPolicy

I added the library spring-retry and then tests worked. Why is this library missing in the 2.0.8? Is it intentional? Do we need to provide any other configuration to make it work? It was working all fine with 2.0.2.RELEASE.

With all these changes (adding rabbit and retry), the application deployment failed with error "Error creating bean with name 'amqpAdmin' defined in class path ".

Logs : -

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'amqpAdmin' defined in class path resource [com/sap/bs/businesslogging/config/CloudRabbitMqContext.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.amqp.core.AmqpAdmin]: Factory method 'amqpAdmin' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/amqp/AmqpResourceNotAvailableException","\tat org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:587)","\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1250)","\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099)","\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)","\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)","\tat org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312)","\tat org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)","\tat org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)","\tat org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)","\tat org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760)","\tat org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868)","\tat org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)","\tat org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)","\tat org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)","\tat org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388)","\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:327)","\tat com.sap.bs.businesslogging.Application.main(Application.java:14)","\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)","\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)","\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)","\tat java.lang.reflect.Method.invoke(Method.java:498)","\tat org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)","\tat org.springframework.boot.loader.Launcher.launch(Launcher.java:87)","\tat org.springframework.boot.loader.Launcher.launch(Launcher.java:50)","\tat org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)","Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.amqp.core.AmqpAdmin]: Factory method 'amqpAdmin' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/amqp/AmqpResourceNotAvailableException","\tat org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)","\tat org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579)","\t... 24 more","Caused by: java.lang.NoClassDefFoundError: org/springframework/amqp/AmqpResourceNotAvailableException","\tat org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:469)","\tat org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:628)","\tat org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.createConnection(ConnectionFactoryUtils.java:240)","\tat org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1816)","\tat org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1790)","\tat org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1771)","\tat org.springframework.amqp.rabbit.core.RabbitAdmin.declareQueue(RabbitAdmin.java:240)","\tat com.sap.bs.businesslogging.config.CloudRabbitMqContext.amqpAdmin(CloudRabbitMqContext.java:33)","\tat com.sap.bs.businesslogging.config.CloudRabbitMqContext$$EnhancerBySpringCGLIB$$a734dafa.CGLIB$amqpAdmin$0()","\tat com.sap.bs.businesslogging.config.CloudRabbitMqContext$$EnhancerBySpringCGLIB$$a734dafa$$FastClassBySpringCGLIB$$ebcdcc33.invoke()","\tat org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)","\tat org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361)","\tat com.sap.bs.businesslogging.config.CloudRabbitMqContext$$EnhancerBySpringCGLIB$$a734dafa.amqpAdmin()","\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)","\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)","\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)","\tat java.lang.reflect.Method.invoke(Method.java:498)","\tat org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)","\t... 25 more","Caused by: java.lang.ClassNotFoundException: org.springframework.amqp.AmqpResourceNotAvailableException","\tat java.net.URLClassLoader.findClass(URLClassLoader.java:443)","\tat java.lang.ClassLoader.loadClass(ClassLoader.java:486)","\tat org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:93)","\tat java.lang.ClassLoader.loadClass(ClassLoader.java:419)","\t... 43 more"] }

Thank, Neha

Comment From: garyrussell

It sounds like yourcopy of the jar is corrupt somehow - I just wrote a new boot application with 2.0.8, and I see spring-retry is on the classpath as expected and the application runs fine.

Comment From: garyrussell

AmqpResourceNotAvailableException was added to spring-amqp 2.0.3 - did you also upgrade that to 2.0.8?

If you use maven or gradle to manage your dependencies you don't need an explicit dependency for this, it is a transitive dependency of the spring-rabbit jar.

Unless you are using an older Spring Boot; in which case you would need to specify a version, but it would be better to upgrade boot as well (to 2.0.6).

Comment From: nehasonisap

Sorry for the delay in response, I was not at work.

We are using 2.0.0 of Spring boot. Recently we started getting some vulnerability issues for spring-rabbit-2.0.2 CVE-2018-11087. To fix this we needed to upgrade to spring-rabbit:2.1.1.

With this we are facing the issues.

I will give it a try once again since you mentioned that spring-retry is available and i could not see it. I will update the issue accordingly.

Comment From: nehasonisap

The issue got fixed after i updated the spring rabbit and spring-amqp to 2.1.1.RELEASE.

Just one clarification, Interface 'ChannelAwareMessageListener' moved from 'org.springframework.amqp.rabbit.core' to 'org.springframework.amqp.rabbit.listener.api' from 2.1.0.RELEASE onwards. Is there anything else required to make this work as it was working before?

Comment From: garyrussell

You just need to ensure all the jars are compatible - spring-rabbit and spring-amqp must be the same version.

Comment From: garyrussell

Closing due to inactivity; please reopen if you are still having issues.

Comment From: mehtaharsh16

Well there might be different issues. But, what I think is that you haven't used the important dependencies for updating to the version 2.0.8. As per me thee class "org.springframework.retry.RetryPolicy" is not present. Can we add this class inside the dependencies.

The code should add org.springframework.retry inside the dependencies.

Comment From: garyrussell

@mehtaharsh16 Don't comment on old issues (especially those that are nearly 5 years old). Also, 2.0.x is no longer supported; see https://spring.io/projects/spring-amqp#support

It must be a problem with the way you are consuming this project; spring-retry is already a required (transitive) dependency; currently 2.0.3.

https://github.com/spring-projects/spring-amqp/blob/4cf9b5c2c5b08f4dbca16c7d94c4e7ac618f3a04/build.gradle#L363

https://github.com/spring-projects/spring-amqp/blob/4cf9b5c2c5b08f4dbca16c7d94c4e7ac618f3a04/build.gradle#L71

If you can't figure it out, use the Discussions tab above to start a Q&A, or ask a question on Stack Overflow. In either case, show your code, configuration, POM etc.

Comment From: artembilan

@sahajkathiriya ,

What is a goal with your message? The issue is very old and closed with all the appropriate patches and reports. So, not clear what sigh we should get from your comment .