Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not refresh JMS Connection for destination 'queue://inventorydsDestination' - retrying in 5000 ms. Cause: AOP configuration seems to be invalid

I'm getting the following exception when I re-deploy the application war in the Tomcat manager. For example, on first time deployment it connects to the external ActiveMQ properly but when I stop/start the war in Tomcat manager, then the following execption is thrown repeatedly. After this, the JMS does not connect to ActiveMQ with the below exception:

[2015-09-13T04:03:33.689] | [ERROR] | [inventorydsRequestListenerContainer-1] | [Could not refresh JMS Connection for destination 'queue://inventorydsDestination' - retrying in 5000 ms. Cause: AOP configuration seems to be invalid: tried calling method [public abstract javax.jms.Connection javax.jms.ConnectionFactory.createConnection() throws javax.jms.JMSException] on target [org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter@168d95c7]; nested exception is java.lang.IllegalArgumentException: java.lang.ClassCastException@2fb6f3c3]

applicationContext-Jms.xml

<bean id="jmsJndiConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
   <property name="jndiName" value="${inventory.mq.name}"/>
   <property name="lookupOnStartup" value="false"/>
   <property name="cache" value="true" />
   <property name="proxyInterface"  value="javax.jms.QueueConnectionFactory" />
</bean>

<bean id="jmsConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
    <property name="targetConnectionFactory" ref="jmsJndiConnectionFactory" />
    <property name="sessionCacheSize" value="10" />
</bean>

connectionFactory - JNDI configuration

<bean id="jndiName" class="java.lang.String">
    <constructor-arg value="${inventory.mq.name}"/>
</bean>

<bean id="bindingObject" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
        <property name="targetConnectionFactory" ref="mqConnectionFactory" />
        <property name="username" value="${inventory.activeMQ.username}" />
        <property name="password" value="${inventory.activeMQ.password}" />
</bean>

<bean id="mqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="${inventory.activeMQ.brokerurl}" />
</bean>

Properties:

inventory.activeMQ.brokerurl=tcp://localhost:61616
inventory.activeMQ.username=admin 
inventory.activeMQ.password=admin
inventory.mq.name=jms/connectionFactory
inventory.queue.type=org.apache.activemq.command.ActiveMQQueue
like image 257
Santosh Babu Dronamraju Avatar asked Nov 27 '22 15:11

Santosh Babu Dronamraju


1 Answers

I had similar issue and discovered it was a classpath issue between tomcat and my web application. I needed to set the scope of the jms dependency in my web app to provided instead of the default (i.e. compile). That way, my WAR deployable did not contain another jms jar that clashed with the jms classes contained in the apache-activemq-all jar that was located in the tomcat lib folder.

    <dependency>
        <groupId>javax.jms</groupId>
        <artifactId>jms-api</artifactId>
        <version>1.1-rev-1</version>
        <scope>provided</scope>
    </dependency>
like image 59
Kurt Hartmann Avatar answered Dec 06 '22 04:12

Kurt Hartmann