Cannot convert value of type [org.apache.activemq.ra.ActiveMQConnectionFactory] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory'

Latest response

Hello,

I have setup JBoss EAP 7.3 and configured the resource adapter subsystem to use it with embedded ActiveMQ 5.6.0

In standalone-full.xml , the connection factory object is defined in the resource adapter subsystem as "org.apache.activemq.ra.ActiveMQManagedConnectionFactory"

The resource adapter subsystem in Jboss standalone-full.xml is as follows:

<subsystem xmlns="urn:jboss:domain:resource-adapters:5.0">
            <resource-adapters>
                <resource-adapter id="activemq-ra.rar">
                    <archive>
                        activemq-ra.rar
                    </archive>
                    <transaction-support>XATransaction</transaction-support>
                    <config-property name="ServerUrl">vm://localhost</config-property>
                    <connection-definitions>
                        <connection-definition class-name="org.apache.activemq.ra.ActiveMQManagedConnectionFactory" jndi-name="java:/activemq/QueueConnectionFactory" enabled="true" use-java-context="true" pool-name="ActiveMQConnectionFactoryPool" use-ccm="true">
                            <xa-pool>
                                <min-pool-size>1</min-pool-size>
                                <max-pool-size>2000</max-pool-size>
                            </xa-pool>
                        </connection-definition>
                    </connection-definitions>
                    <admin-objects>
                        <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name=
                        <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:/queue/HELLOWORLDMDBQueue" use-java-context="true" pool-name="HELLOWORLDMDBQueue">
                            <config-property name="PhysicalName">HELLOWORLDMDBQueue</config-property>
                        </admin-object>                     
                        <admin-object class-name="org.apache.activemq.command.ActiveMQTopic" jndi-name="java:/topic/HELLOWORLDMDBTopic" use-java-context="true" pool-name="HELLOWORLDMDBTopic">
                            <config-property name="PhysicalName">HELLOWORLDMDBTopic</config-property>
                        </admin-object>                        
                    </admin-objects>
                </resource-adapter>
            </resource-adapters>
        </subsystem>

But my application which uses spring JMS Template to send and receive messages is expecting a connection factory object of type javax.jms.ConnectionFactory.
This connection factory is a property in the JMSTemplate bean as follows:

<jee:jndi-lookup id="connectionFactory" jndi-name="java:/activemq/QueueConnectionFactory"/>

<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory" ref="connectionFactory" />
        <property name="defaultDestination" ref="abcdQueue" />
</bean>

Because of this type difference i am getting the following exception when deploying my app in JBoss.

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsTemplate' defined in class path resource [core-config.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.apache.activemq.ra.ActiveMQConnectionFactory' to required type 'javax.jms.ConnectionFactory' for property 'connectionFactory'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.apache.activemq.ra.ActiveMQConnectionFactory] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
...
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.apache.activemq.ra.ActiveMQConnectionFactory' to required type 'javax.jms.ConnectionFactory' for property 'connectionFactory'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.apache.activemq.ra.ActiveMQConnectionFactory] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found

I have removed/commented out the messaging subsystem in standalone-full.xml so that the activemq-ra.rar that comes with activeMQ Artemis doesn't interfere with the one i am using(I have placed activemq-ra.rar file in JBoss deployment directory)

I have attached my standalone-full.xml

My Environment is as below
JBoss EAP 7.3.0 with Embedded ActiveMQ 5.6.0
JDK 8
Windows

I am relatively new to JBoss and I really appreciate any guidance on this.

Attachments

Responses

To start with EAP does support embedded AMQ 6 broker. You should be able to use AMQ 6 as an external broker. Having said so I see that you use community version of the broker which has never been tested with EAP 7.3. The error itself implies that most likely you include the javax.jms.ConnectionFactory twice.

I meant Active MQ as internal broker(I think i incorrectly used the term 'embedded' broker). I followed the instructions here ActiveMQ_as_an_internal_messaging_broker

1 . You have used community version of the broker

I only placed the ActiveMQ resource adapter file, ractivemq-ra.rar, in the deployment directory of JBoss.
If you see in the above link in the 'ActiveMQ as an internal messaging broker' section , Installation of Active MQ broker is not needed for internal messaging broker

2 . most likely you include the javax.jms.ConnectionFactory twice

My application has activemq-all-5.6.0 jar included in its maven dependency, and the javax.jms.ConnectionFactory class is coming from there.

<dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-all</artifactId>
            <version>5.6.0</version>
            <scope>provided</scope>
  </dependency>

The issue is resolved , thanks.

The messaging subsystem in standalone-full.xml was commented out , because of that the the javax.jms dependency is not added to the deployment, according to the this article