Configure JMS queue on JBOSS EAP 6.4
Hi All,
I am trying to configure JMS queue with JBOSS EAP 6.4 using spring jms API's. Below are the configuration details -
1] Jboss version : 6.4 EAP
2]Spring version : 4.1.5.RELEASE including jms
3]Below is the configuration details of application-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<context:annotation-config />
<aop:aspectj-autoproxy />
<context:component-scan base-package="com.mohh.nehr.commonUtil" />
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:/portlet.properties</value>
</property>
</bean>
<bean id="jndiTemplate" class="com.mohh.nehr.commonUtil.service.CustomJndiTemplate">
</bean>
<bean id="destination" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate" ref="jndiTemplate"></property>
<property name="jndiName" value="${java.jms.destination}"></property>
</bean>
<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate" ref="jndiTemplate"></property>
<property name="jndiName" value="${java.connectionFactory}"></property>
</bean>
<bean id="queueConnectionFactory"
class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
<property name="targetConnectionFactory" ref="connectionFactory"></property>
<property name="username" value="${java.jms.username}"></property>
<property name="password" value="${java.jms.password}"></property>
</bean>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="queueConnectionFactory"></property>
<property name="defaultDestination" ref="destination" />
</bean>
<bean id="messageListenerReceiver"
class="com.mohh.nehr.commonUtil.audit.AccessLoggerListener">
</bean>
<bean id="messageListenerContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="queueConnectionFactory"></property>
<property name="destination" ref="destination"></property>
<property name="messageListener" ref="messageListenerReceiver"></property>
</bean>
In addition i am using pretty much template api and code nothing fancy. It worked successfully on my local when i tried to run using standalone java program but when i deployed on DEV environment i am getting below error.
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.hornetq.jms.client.HornetQJMSConnectionFactory' to required type 'javax.jms.ConnectionFactory' for property 'connectionFactory'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.hornetq.jms.client.HornetQJMSConnectionFactory] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:476)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:512)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:506)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1515)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1474)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
... 269 common frames
I am really not sure from where its picking the class org.hornetq.jms.client.HornetQJMSConnectionFactory as i havent provided any reference of it in aplication-context.xml. In addition i am passing all dependencies like springJms, jbossClient in provided mode so that they will be provided by container.
Any help will be highly appreciated.
Responses
I suspect that your issue is with ${java.connectionFactory}. What does it point at in JBoss JNDI registry?
Are you running this spring application as standalone or inside JBoss EAP? If you are running it inside JBoss EAP then you shouldn't be using jms/RemoteConnectionFactory.
5 years later I now but in case someone is in the same problem here is what I faced when trying to deploy a spring boot jms listener with the error org.hornetq.jms.client.HornetQJMSConnectionFactory cannot be cast to javax.jms.ConnectionFactory . The problem in my case was that I was attaching a jms library jar to my aplication archive lib folder. what I did to make it work was to change the dependency to provided on every jms related maven dependency and also added an entry in jboss-deployment-structure.xml dependencies for the jms modules org.hornetq , org.hornetq.ra and javax.jms.api making de application code completely dependent in the jboss modules classloader/class definition for this classes.