0
votes

I have a HornetQ JMS queue set on JBoss EAP6, in the standalone.xml file.

<hornetq-server>
[...]
    <jms-connection-factories>
        <connection-factory name="RemoteConnectionFactory">
            <connectors>
                <connector-ref connector-name="netty"/>
            </connectors>
            <entries>
                <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
            </entries>
        </connection-factory>
    </jms-connection-factories>

    <jms-destinations>
        <jms-queue name="WorkflowExecution">
            <entry name="/queue/MyQueue"/>
            <entry name="java:jboss/exported/queue/MyQueue"/>
        </jms-queue>
    </jms-destinations>
</hornetq-server>

The queue works fine, and I can send messages on it using tools like Hermes JMS.

I'm working on a standalone client application, running in Fuse 4.4, that has to send a message to the queue via a Camel route but I can't figure out how to set the connector in the configuration.

This is what I tried to set in the camel-context.xml file:

<bean id="jmsinjection" class="org.apache.camel.component.jms.JmsComponent">
  <property name="connectionFactory">
    <bean class="org.springframework.jndi.JndiObjectFactoryBean">
      <property name="jndiName" value="jms/RemoteConnectionFactory" />
      <property name="jndiEnvironment">
        <props>
          <prop key="java.naming.provider.url">remote://myEAPurl:port</prop>
          <prop key="java.naming.factory.initial">org.jboss.naming.remote.client.InitialContextFactory</prop>
        </props>
      </property>
    </bean>
  </property>
</bean>

And the exception I get:

Error creating bean with name 'jmsinjection' defined in URL [bundle://79.37:0/META-INF/spring/camel-context.xml]: Initialization of bean failed; nested exception is 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

According to the javadoc, HornetQJMSConnectionFactory implements javax.jms.QueueConnectionFactory which extends javax.jms.ConnectionFactory, so I don't get why I get this exception.

I spent hours scraping JBoss forum and doc but can't find a way to make it work.

What is wrong in my camel configuration? How to fix it?

1
have you tried an explicit conversion?Francisco Melo junior
@FranciscoMelojunior could you explain?jhamon

1 Answers

1
votes

The problem is due to the OSGi class-loader.

Fuse ESB already has a version of javax.jms.ConnectionFactory loaded in the classpath.

Adding the jboss-client.jar does add the HornetQJMSConnectionFactory to the classpath but also another version of the ConnectionFactory.

The solution is to add all the following dependencies to the bundle and remove the jboss-client.jar as indicated on this page:

hornetq-core
hornetq-jms
jboss-ejb-client
jboss-logging
jboss-logmanager
jboss-marshalling
jboss-marshalling-river
jboss-remote-naming
jboss-remoting
jboss-sasl
netty
remoting-jmx
xnio-api
xnio-nio

You can find all those dependencies with the correct version directly on your JBoss EAP instance repository. Names may be a bit different.