2 Replies Latest reply on Oct 18, 2010 11:01 AM by Mark Hansen

    HornetQConnectionFactory not assignable to javax.jms.ConnectionFactory

    Mark Hansen Newbie

      I've installed HornetQ 2.1.1.Final in JBoss AS 5.1.0.GA.  I'm able to run the examples/javaee/mdb-cmt-tx-local example.

       

      Now, I am trying to incorporate HornetQ ad the JMS provider for a Spring application.  I'm getting this error from the Spring ContextLoader, indicating that HornetQConnectionFactory does not implement javax.jms.ConnectionFactory.  Does anyone have any ideas why this might be happening?

       

      Error creating bean with name 'connectionFactory': Invocation of init method failed; nested exception is org.springframework.jndi.TypeMismatchNamingException: Object of type [class org.hornetq.jms.client.HornetQConnectionFactory] available at JNDI location [java:/ConnectionFactory] is not assignable to [javax.jms.ConnectionFactory]

       

      Here is the Spring definition of the JNDI lookup that is throwing this exception:

       

      <jee:jndi-lookup id="connectionFactory" jndi-name="java:/ConnectionFactory"
              environment-ref="jndiJBossProps" expected-type="javax.jms.ConnectionFactory"/>

       

      If I remove the "expected-type" attribute, I just get the same cast error in another place, when Spring tries to use the connectionFactory.

       

      Here are the relevant configuration files:

       

      hornetq.sar/hornetq-jms.xml

      ======================

      <configuration xmlns="urn:hornetq"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">

       

         <connection-factory name="NettyConnectionFactory">
            <connectors>
               <connector-ref connector-name="netty"/>
            </connectors>
            <entries>
               <entry name="/ConnectionFactory"/>
               <entry name="/XAConnectionFactory"/>
            </entries>
         </connection-factory>
        
         <connection-factory name="NettyThroughputConnectionFactory">
             <connectors>
               <connector-ref connector-name="netty-throughput"/>
             </connectors>
              <entries>
                  <entry name="/ThroughputConnectionFactory"/>
                  <entry name="/XAThroughputConnectionFactory"/>
              </entries>
          </connection-factory>
        
         <connection-factory name="InVMConnectionFactory">
            <connectors>
               <connector-ref connector-name="in-vm"/>
            </connectors>
            <entries>
               <entry name="java:/ConnectionFactory"/>
               <entry name="java:/XAConnectionFactory"/>
            </entries>
         </connection-factory>
        
         <queue name="DLQ">
            <entry name="/queue/DLQ"/>
         </queue>
        
         <queue name="ExpiryQueue">
            <entry name="/queue/ExpiryQueue"/>
         </queue>

       

         <queue name="cilErrorQueue">
            <entry name="/queue/cilErrorQueue"/>
         </queue>

       

      </configuration>

       

       

      hornetq.sar/hornetq-configuration.xml

      =============================

      <configuration xmlns="urn:hornetq"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">

       

         <log-delegate-factory-class-name>org.hornetq.integration.logging.Log4jLogDelegateFactory</log-delegate-factory-class-name>
        
         <bindings-directory>${jboss.server.data.dir}/hornetq/bindings</bindings-directory>

       

         <journal-directory>${jboss.server.data.dir}/hornetq/journal</journal-directory>
        
         <journal-min-files>10</journal-min-files>
        
         <large-messages-directory>${jboss.server.data.dir}/hornetq/largemessages</large-messages-directory>

       

         <paging-directory>${jboss.server.data.dir}/hornetq/paging</paging-directory>

       

         <connectors>
            <connector name="netty">
               <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
               <param key="host"  value="${jboss.bind.address:localhost}"/>
               <param key="port"  value="${hornetq.remoting.netty.port:5445}"/>
            </connector>
           
            <connector name="netty-throughput">
               <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
               <param key="host"  value="${jboss.bind.address:localhost}"/>
               <param key="port"  value="${hornetq.remoting.netty.batch.port:5455}"/>
               <param key="batch-delay" value="50"/>
            </connector>

       

            <connector name="in-vm">
               <factory-class>org.hornetq.core.remoting.impl.invm.InVMConnectorFactory</factory-class>
               <param key="server-id" value="${hornetq.server-id:0}"/>
            </connector>

       

         </connectors>

       

         <acceptors>  
            <acceptor name="netty">
               <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
               <param key="host"  value="${jboss.bind.address:localhost}"/>
               <param key="port"  value="${hornetq.remoting.netty.port:5445}"/>
            </acceptor>
           
            <acceptor name="netty-throughput">
               <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
               <param key="host"  value="${jboss.bind.address:localhost}"/>
               <param key="port"  value="${hornetq.remoting.netty.batch.port:5455}"/>
               <param key="batch-delay" value="50"/>
               <param key="direct-deliver" value="false"/>
            </acceptor>

       

            <acceptor name="in-vm">
              <factory-class>org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory</factory-class>
              <param key="server-id" value="0"/>
            </acceptor>

       

         </acceptors>

       

         <security-settings>
            <security-setting match="#">
               <permission type="createNonDurableQueue" roles="guest"/>
               <permission type="deleteNonDurableQueue" roles="guest"/>
               <permission type="consume" roles="guest"/>
               <permission type="send" roles="guest"/>
            </security-setting>
         </security-settings>

       

         <address-settings>
            <!--default for catch all-->
            <address-setting match="#">
               <dead-letter-address>jms.queue.DLQ</dead-letter-address>
               <expiry-address>jms.queue.ExpiryQueue</expiry-address>
               <redelivery-delay>0</redelivery-delay>
               <max-size-bytes>10485760</max-size-bytes>      
               <message-counter-history-day-limit>10</message-counter-history-day-limit>
               <address-full-policy>BLOCK</address-full-policy>
            </address-setting>
         </address-settings>

       

      </configuration>