When I try to upgrade spring ampq from 1.3.4.RELEASE to 1.5.5.RELEASE I'm facing below error. It was working fine but when I try to upgrade its throwing an error. Any suggestions would be helpful. Here is my dependency details.
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
<version>1.5.5.RELEASE</version>
<exclusions>
<exclusion>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>4.8.0</version>
</dependency>
spring version I'm using is 4.2.3.RELEASE
Error details :-
21-Feb-2023 16:12:58.148 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'que' defined in class path resource [config/spring/config-amqp.xml]: Cannot resolve reference to bean 'test' while setting bean property 'listeners' with key [0]; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'test' is defined
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:382)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:157)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1481)
here is my config xml file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xmlns:rabbit="http://www.springframework.org/schema/rabbit" xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit-1.3.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd">
<beans profile="info">
<!-- Consumers -->
<rabbit:listener-container id="test"
transaction-size="2" prefetch="2" error-handler="handler"
connection-factory="connectionFactory" acknowledge="auto"
concurrency="${t1.consmers}" advice-chain="valueTester">
<rabbit:listener queues="${t2.consumer}, ${t3.tester}"
ref="testConsumer" method="consume" />
</rabbit:listener-container>
<!-- Consumers manager -->
<bean id="someid" class="java.util.concurrent.ConcurrentLinkedQueue" />
<bean id="queue" class="com.t1.QueueTester">
<property name="listeners">
<list>
<ref bean="test" />
</list>
</property>
</bean>
</beans>
<beans profile="build"></beans>
</beans>
See what was new for that version back in days: https://docs.spring.io/spring-amqp/docs/current/reference/html/#listener-container-bean-names-xml
When migrating to this release, if you have id attributes on your
<listener-container/>
elements, remove them and set the id on the child<listener/>
element instead.
The reason behind this that you had to specify both ids in the past to get access to respective listener.
It is better to upgrade to the latest version anyway: all those are out of support for years.