4 Replies Latest reply on May 5, 2010 4:48 PM by Alexander Sanchez

    why the Jboss server is using the jms-ra adapter (org.jboss.resource.adapter.jms.JmsResourceAdapter) instead of using the hornetq-ra adapter (org.hornetq.ra.HornetQResourceAdapter) ?

    Alexander Sanchez Newbie

      Hello, my scenary is this:

       

      esquemaQueue.png

       

      I followed:

       

      • 5.3.  HornetQ integrated with a JEE application server
      • 32.   Application Server Integration and Java EE
      • Example 11.3.3.   Resource Adapter Configuration

       

      In the jboss  aplication server, I did this:

       

            1) I copied the  hornetq-ra.rar adapter file  in directory jboss-4.2.3.GA\server\default\deploy\jms\

            2) I opened the hornetq-ra.rar file and I  edited the ra.xml file that found under directory  hornetq-ra.rar\META-INF

       

      ra.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <connector xmlns="http://java.sun.com/xml/ns/j2ee"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee  http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"  version="1.5">
         <description>HornetQ 2.0 Resource Adapter</description>
         <display-name>HornetQ 2.0 Resource Adapter</display-name>
         <vendor-name>Red Hat Middleware LLC</vendor-name>
         <eis-type>JMS 1.1 Server</eis-type>
         <resourceadapter-version>1.0</resourceadapter-version>
         <license>
            <description>
                Copyright 2009 Red Hat, Inc. Red Hat licenses this file to you under the Apache License, version  2.0 (the "License"); you may not use this  file except in compliance with the License.  You may obtain a copy of the License at    http://www.apache.org/licenses/LICENSE-2.0
      Unless required by applicable law or agreed to in writing, software  distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  implied.  See the License for the specific language governing
      permissions and limitations under the License. 
            </description>
            <license-required>true</license-required>
         </license>

         <resourceadapter>
            <resourceadapter-class>org.hornetq.ra.HornetQResourceAdapter</resourceadapter-class>
            <config-property>
               <description>The transport type</description>
               <config-property-name>ConnectorClassName</config-property-name>
               <config-property-type>java.lang.String</config-property-type>
               <config-property-value>org.jboss.messaging.integration.transports.netty.NettyConnectorFactory</config-property-value>
            </config-property>
            <config-property>
               <description>The transport configuration. These values must be in the form of key=val;key=val;</description>
               <config-property-name>ConnectionParameters</config-property-name>
               <config-property-type>java.lang.String</config-property-type>
               <config-property-value>hornetq.remoting.netty.host=192.168.1.144;hornetq.remoting.netty.port=5445</config-property-value>
            </config-property>
            <config-property>
              <description>Use XA?</description>
              <config-property-name>UseXA</config-property-name>
              <config-property-type>java.lang.Boolean</config-property-type>
              <config-property-value>true</config-property-value>
            </config-property>
        
            <outbound-resourceadapter>
               <connection-definition>
                  <managedconnectionfactory-class>org.hornetq.ra.HornetQRAManagedConnectionFactory</managedconnectionfactory-class>
                  <config-property>
                     <description>The default session type</description>
                     <config-property-name>SessionDefaultType</config-property-name>
                     <config-property-type>java.lang.String</config-property-type>
                     <config-property-value>javax.jms.Queue</config-property-value>
                  </config-property>
                  <config-property>
                     <description>Try to obtain a lock within specified number of seconds; less than or equal to 0 disable this functionality</description>
                     <config-property-name>UseTryLock</config-property-name>
                     <config-property-type>java.lang.Integer</config-property-type>
                     <config-property-value>0</config-property-value>
                  </config-property>

                  <connectionfactory-interface>org.hornetq.ra.HornetQRAConnectionFactory</connectionfactory-interface>
                  <connectionfactory-impl-class>org.hornetq.ra.HornetQRAConnectionFactoryImpl</connectionfactory-impl-class>
                  <connection-interface>javax.jms.Session</connection-interface>
                  <connection-impl-class>org.hornetq.ra.HornetQRASession</connection-impl-class>
               </connection-definition>

               <transaction-support>XATransaction</transaction-support>
               <authentication-mechanism>
                  <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
                  <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
               </authentication-mechanism>

               <reauthentication-support>false</reauthentication-support>
            </outbound-resourceadapter>

            <inbound-resourceadapter>
               <messageadapter>
                  <messagelistener>
                     <messagelistener-type>javax.jms.MessageListener</messagelistener-type>
                     <activationspec>
                        <activationspec-class>org.hornetq.ra.inflow.HornetQActivationSpec</activationspec-class>
                        <required-config-property>
                            <config-property-name>destination</config-property-name>
                        </required-config-property>
                     </activationspec>
                  </messagelistener>
               </messageadapter>
            </inbound-resourceadapter>
         </resourceadapter>
      </connector>

       

       

      The  line

       

      <config-property-value>hornetq.remoting.netty.host=192.168.1.144;hornetq.remoting.netty.port=5445</config-property-value>

       

      was  edited so I could establish a connetion to the hornetq server that is  running on other server (ip: 192.168.1.144).

       

      3) In the  MDB :

       

      package HornetQ;
      import javax.ejb.MessageDriven;
      import javax.ejb.ActivationConfigProperty;
      import javax.jms.JMSException;
      import javax.jms.Message;
      import javax.jms.MessageListener;
      import javax.jms.ObjectMessage;
      import javax.jms.TextMessage;

       


      import org.jboss.ejb3.annotation.ResourceAdapter;

       


      @MessageDriven(name = "MDBExample",
              activationConfig =
              {
              @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
              @ActivationConfigProperty(propertyName="destination", propertyValue="queues/OrderQueue")
              })
      @ResourceAdapter("hornetq-ra.rar")       
      public class MDBExample  implements MessageListener
      {

       


          @Override
          public void onMessage(Message recvMsg) {
              .......
          }
      }

       

      4)  In jboss.xml

       

      <?xml version="1.0" encoding="UTF-8"?>
      <jboss>
          <enterprise-beans>
              <message-driven>
                     <ejb-name>ExampleMDB</ejb-name>
                     <resource-adapter-name>hornetq-ra.rar</resource-adapter-name>
              </message-driven>       
          </enterprise-beans>
      </jboss>

       

       

      When  I publish the project this error appears:

       

      17:01:31,923 WARN  [JmsActivation] Failure in jms activation org.jboss.resource.adapter.jms.inflow.JmsActivationSpec@18efc0c(ra=org.jboss.resource.adapter.jms.JmsResourceAdapter@c07f58 destination=queues/OrderQueue isTopic=false tx=true durable=false reconnect=10 provider=java:/DefaultJMSProvider user=null maxMessages=1 minSession=1 maxSession=15 keepAlive=60000 useDLQ=true DLQHandler=org.jboss.resource.adapter.jms.inflow.dlq.GenericDLQHandler DLQJndiName=queue/DLQ DLQUser=null DLQMaxResent=5)
      javax.naming.NameNotFoundException: queues not bound
          at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
          at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
          at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
          at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
          at javax.naming.InitialContext.lookup(Unknown Source)
          at org.jboss.util.naming.Util.lookup(Util.java:215)
          at org.jboss.resource.adapter.jms.inflow.JmsActivation.setupDestination(JmsActivation.java:409)
          at org.jboss.resource.adapter.jms.inflow.JmsActivation.setup(JmsActivation.java:316)
          at org.jboss.resource.adapter.jms.inflow.JmsActivation$SetupActivation.run(JmsActivation.java:635)
          at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:204)
          at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:275)
          at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:756)
          at java.lang.Thread.run(Unknown Source)

       

      The line:

       

      Failure in jms activation org.jboss.resource.adapter.jms.inflow.JmsActivationSpec@18efc0c
      (ra=org.jboss.resource.adapter.jms.JmsResourceAdapter@c07f58 destination=queues/OrderQueue isTopic=false tx=true durable=false reconnect=10 provider=java:/DefaultJMSProvider user=null maxMessages=1 minSession=1 maxSession=15 keepAlive=60000 useDLQ=true DLQHandler=org.jboss.resource.adapter.jms.inflow.dlq.GenericDLQHandler DLQJndiName=queue/DLQ DLQUser=null DLQMaxResent=5)
      javax.naming.NameNotFoundException: queues not bound

       

      Seems that the  Jboss server is using the jms-ra adapter  (org.jboss.resource.adapter.jms.JmsResourceAdapter) to connect with  destination "queues/OrderQueue" instead of using the hornetq-ra adapter  (org.hornetq.ra.HornetQResourceAdapter) that is on the remote hornetq  server.

       

      Please help me to find the error.

        • 2. Re: why the Jboss server is using the jms-ra adapter (org.jboss.resource.adapter.jms.JmsResourceAdapter) instead of using the hornetq-ra adapter (org.hornetq.ra.HornetQResourceAdapter) ?
          Ben Schofield Novice

          Try this little tid bit at the end of section 32.1 of the hornetq user manual.

           

          "You can also rename the hornetq-ra.rar directory to jms-ra.rar and neither the annotation or the extra descriptor information
          will be needed. If you do this you will need to edit the jms-ds.xml datasource file and change rar-name
          element."

           

          I don't remember the details but I think this resolved the exact same error I had earlier.

          • 3. Re: why the Jboss server is using the jms-ra adapter (org.jboss.resource.adapter.jms.JmsResourceAdapter) instead of using the hornetq-ra adapter (org.hornetq.ra.HornetQResourceAdapter) ?
            jaikiran pai Master
            import org.jboss.ejb3.annotation.ResourceAdapter
            org.jboss.ejb3.annotation.ResourceAdapter is meant for JBoss AS-5.x and later versions. It won't work on JBoss AS-4.

            For JBoss AS-4, you'll have to use @org.jboss.annotation.ejb.ResourceAdaptor
            • 4. Re: Problem solved
              Alexander Sanchez Newbie

              Hello, my problem has been resolved, I did  thus:

               

                     I followed section 32.1 of the hornetq user manual.

               

              You can also rename the hornetq-ra.rar directory to jms-ra.rar and neither the annotation or the extra 
              descriptor information will be needed. If you do this you will need to edit the jms-ds.xml datasource file 
              and change rar-name  element.
              

               

                  1) I copied the  hornetq-ra.rar adapter file  in directory jboss-4.2.3.GA\server\default\deploy\jms\

                  2) I edited ra.xml file that found under directory  hornetq-ra.rar\META-INF

               

               

              <?xml version="1.0" encoding="UTF-8"?>
              <!-- $Id: ra.xml 76819 2008-08-08 11:04:20Z jesper.pedersen $ -->
              <connector xmlns="http://java.sun.com/xml/ns/j2ee"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                         http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
                         version="1.5">
              
              
                 <description>HornetQ 2.0 Resource Adapter</description>
                 <display-name>HornetQ 2.0 Resource Adapter</display-name>
              
              
                 <vendor-name>Red Hat Middleware LLC</vendor-name>
                 <eis-type>JMS 1.1 Server</eis-type>
                 <resourceadapter-version>1.0</resourceadapter-version>
              
              
                 <license>
                    <description>
              Copyright 2009 Red Hat, Inc.
               Red Hat licenses this file to you under the Apache License, version
               2.0 (the "License"); you may not use this file except in compliance
               with the License.  You may obtain a copy of the License at
                 http://www.apache.org/licenses/LICENSE-2.0
               Unless required by applicable law or agreed to in writing, software
               distributed under the License is distributed on an "AS IS" BASIS,
               WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
               implied.  See the License for the specific language governing
               permissions and limitations under the License.  
                    </description>
                    <license-required>true</license-required>
                 </license>
              
              
                 <resourceadapter>
                    <resourceadapter-class>org.hornetq.ra.HornetQResourceAdapter</resourceadapter-class>
                    <config-property>
                       <description>The transport type</description>
                       <config-property-name>ConnectorClassName</config-property-name>
                       <config-property-type>java.lang.String</config-property-type>         
                       <!--config-property-value>org.hornetq.core.remoting.impl.invm.InVMConnectorFactory</config-property-value-->
                       <config-property-value>org.hornetq.integration.transports.netty.NettyConnectorFactory</config-property-value>
                    </config-property>
                    <config-property>
                       <description>The transport configuration. These values must be in the form of key=val;key=val;</description>
                       <config-property-name>ConnectionParameters</config-property-name>
                       <config-property-type>java.lang.String</config-property-type>
                       <config-property-value>host=192.168.1.144;port=5445</config-property-value>
                    </config-property>
              
              
                    <config-property>
                      <description>Use XA?</description>
                      <config-property-name>UseXA</config-property-name>
                      <config-property-type>java.lang.Boolean</config-property-type>
                      <config-property-value>true</config-property-value>
                    </config-property>
              
              
              
                    <outbound-resourceadapter>
                       <connection-definition>
                          <managedconnectionfactory-class>org.hornetq.ra.HornetQRAManagedConnectionFactory</managedconnectionfactory-class>
              
              
                          <config-property>
                             <description>The default session type</description>
                             <config-property-name>SessionDefaultType</config-property-name>
                             <config-property-type>java.lang.String</config-property-type>
                             <config-property-value>javax.jms.Queue</config-property-value>
                          </config-property>
                          <config-property>
                             <description>Try to obtain a lock within specified number of seconds; less than or equal to 0 disable this functionality</description>
                             <config-property-name>UseTryLock</config-property-name>
                             <config-property-type>java.lang.Integer</config-property-type>
                             <config-property-value>0</config-property-value>
                          </config-property>
              
              
                          <connectionfactory-interface>org.hornetq.ra.HornetQRAConnectionFactory</connectionfactory-interface>
                          <connectionfactory-impl-class>org.hornetq.ra.HornetQRAConnectionFactoryImpl</connectionfactory-impl-class>
                          <connection-interface>javax.jms.Session</connection-interface>
                          <connection-impl-class>org.hornetq.ra.HornetQRASession</connection-impl-class>
                       </connection-definition>
                       <transaction-support>XATransaction</transaction-support>
                       <authentication-mechanism>
                          <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
                          <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
                       </authentication-mechanism>
                       <reauthentication-support>false</reauthentication-support>
                    </outbound-resourceadapter>
              
              
                    <inbound-resourceadapter>
                       <messageadapter>
                          <messagelistener>
                             <messagelistener-type>javax.jms.MessageListener</messagelistener-type>
                             <activationspec>
                                <activationspec-class>org.hornetq.ra.inflow.HornetQActivationSpec</activationspec-class>
                                <required-config-property>
                                    <config-property-name>destination</config-property-name>
                                </required-config-property>
                             </activationspec>
                          </messagelistener>
                       </messageadapter>
                    </inbound-resourceadapter>
              
              
                 </resourceadapter>
              </connector>
              
              

               

              The lines:

               

              <config-property-value>org.hornetq.integration.transports.netty.NettyConnectorFactory</config-property-value>

              and

               

              <config-property-value>host=192.168.1.144;port=5445</config-property-value>


              Those lines are very important for the conection with hornetq, that is installed on a remote server (192.168.1.144)

               

                  3)  I renamed  the hornetq-ra.rar  directory to  jms-ra.rar

               

                   4) I edited I edited jms-ds.xml file that found under directory jboss-4.2.3.GA\server\default\deploy\jms\

               

               

              <?xml version="1.0" encoding="UTF-8"?>
              
              
              <connection-factories>
               
                <!-- ==================================================================== -->
                <!-- JMS Stuff                                                            -->
                <!-- ==================================================================== -->
              
              
                <!-- The JMS provider loader -->
                <mbean code="org.jboss.jms.jndi.JMSProviderLoader"
                   name="jboss.mq:service=JMSProviderLoader,name=JMSProvider">
                  <attribute name="ProviderName">DefaultJMSProvider</attribute>
                  <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
                  <!-- The combined connection factory -->
                  <attribute name="FactoryRef">java:/XAConnectionFactory</attribute>
                  <!-- The queue connection factory -->
                  <attribute name="QueueFactoryRef">java:/XAConnectionFactory</attribute>
                  <!-- The topic factory -->
                  <attribute name="TopicFactoryRef">java:/XAConnectionFactory</attribute>
                  <!-- Uncomment to use HAJNDI to access JMS
                  <attribute name="Properties">
                     java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
                     java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
                     java.naming.provider.url=localhost:1100
                  </attribute>
                  -->
                </mbean>
              
              
                <!-- The server session pool for Message Driven Beans -->
                <mbean code="org.jboss.jms.asf.ServerSessionPoolLoader"
                   name="jboss.mq:service=ServerSessionPoolMBean,name=StdJMSPool">
                  <depends optional-attribute-name="XidFactory">jboss:service=XidFactory</depends>
                  <attribute name="PoolName">StdJMSPool</attribute>
                  <attribute name="PoolFactoryClass">
                    org.jboss.jms.asf.StdServerSessionPoolFactory
                  </attribute>
                </mbean>
              
              
                <!-- JMS XA Resource adapter, use this to get transacted JMS in beans -->
                <!--tx-connection-factory>
                  <jndi-name>JmsXA</jndi-name>
                  <xa-transaction/>
                  <rar-name>jms-ra.rar</rar-name>
                  <connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>
                  <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic</config-property>
                  <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/DefaultJMSProvider</config-property>
                  <security-domain-and-application>JmsXARealm</security-domain-and-application>
                  <max-pool-size>20</max-pool-size>
                </tx-connection-factory-->
               
              <!-- Esto es lo nuevo --> 
               <tx-connection-factory>
                  <jndi-name>JmsXA</jndi-name>
                  <xa-transaction/>
                  <rar-name>jms-ra.rar</rar-name>
                  <connection-definition>org.hornetq.ra.HornetQRAConnectionFactory</connection-definition>
                  <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic</config-property>
                  <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/DefaultJMSProvider</config-property>    
                  <security-domain-and-application>JmsXARealm</security-domain-and-application>
                  <max-pool-size>20</max-pool-size>
                </tx-connection-factory>  
              <!-- Fin de lo nuevo --> 
              </connection-factories>
              

               

              thanks for helping me everyone