6 Replies Latest reply on May 4, 2009 8:07 PM by Len Walter

    Porting WLS8.1 to JBoss5 - JNDI lookup for XA factory return

    Len Walter Newbie

      G'day,

      This is probably a newbie question, but I couldn't find the answer in a few days of Googling. I'm trying to port a JMS-using app from Weblogic 8.1 to JBoss 5.0.

      I've configured a transactional JMS factory like this in jms-ds.xml:

      <tx-connection-factory>
       <jndi-name>applications/ig/jms/INVOICE_GENERATOR_CF</jndi-name>
       <use-java-context>false</use-java-context>
       <xa-transaction/>
       <rar-name>jms-ra.rar</rar-name>
      ..etc..
      



      This is then set up in connection-factories.xml:
      <mbean code="org.jboss.jms.server.connectionfactory.ConnectionFactory"
       name="jboss.messaging.connectionfactory:service=ConnectionFactory"
       xmbean-dd="xmdesc/ConnectionFactory-xmbean.xml">
       <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
       <depends optional-attribute-name="Connector">jboss.messaging:service=Connector,transport=bisocket</depends>
       <depends>jboss.messaging:service=PostOffice</depends>
      
       <attribute name="JNDIBindings">
       <bindings>
       <binding>/ConnectionFactory</binding>
       <binding>/XAConnectionFactory</binding>
       <binding>java:/ConnectionFactory</binding>
       <binding>java:/XAConnectionFactory</binding>
       <binding>applications/ig/jms/INVOICE_GENERATOR_CF</binding>
      ..etc..
      


      The JNDI View mbean then shows me this bound into the global namespace:
      +- applications (class: org.jnp.interfaces.NamingContext)
       | +- ig (class: org.jnp.interfaces.NamingContext)
       | | +- jms (class: org.jnp.interfaces.NamingContext)
       | | | +- INVOICE_GENERATOR_CF (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
      


      So when the code does this:

      Object temp = context.lookup(jndiFactoryName);
      if (temp instanceof XAQueueConnectionFactory) {
       factory = (XAQueueConnectionFactory) temp;
      }
      else {
       log.error("getXAQueueConnectionFactory: Could not cast the object " + temp.toString() + "to a XAQueueConnectionFactory class.");
      }
      


      Sure enough, it logs this:
      2009-04-28 16:01:27,226 ERROR [au.com.soul.common.utils.servicelocator.ServiceLocator] getXAQueueConnectionFactory: Could not cast the object org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl@665e81to a XAQueueConnectionFactory class.
      


      Could someone please point me in the right direction?

      thanks in advance,
      Len

        • 1. Re: Porting WLS8.1 to JBoss5 - JNDI lookup for XA factory re
          Len Walter Newbie

          Sorry, that subject should read "Porting WLS8.1 to JBoss5 - JNDI lookup for XA factory returns wrong class"

          • 2. Re: Porting WLS8.1 to JBoss5 - JNDI lookup for XA factory re
            Yong Hao Gao Master

            Hi ,

            jms-ds.xml is for JCA use. If you use JCA, then use the JCA API. You can't cast it to JBM connection factory.

            To get a JBM connection factory, you need to configure the connection-factories-service.xml. It's under deploy/messaging, take a look and you will know it.

            • 3. Re: Porting WLS8.1 to JBoss5 - JNDI lookup for XA factory re
              Len Walter Newbie

              Thanks for the quick response. I was under the impression I needed JCA for transactional JMS. I've removed the tx-connection-factory and now the code snippet I posted works.

              However.. I now get an error like this:

              2009-04-30 19:15:11,619 ERROR [org.jboss.messaging.util.ExceptionUtil] ConnectionEndpoint[h3-67tn85uf-1-hjjm85uf-wxb1yo-f1rp1a] sendTransaction [w7-rezp85uf-1-hjjm85uf-wxb1yo-f1rp1a]
              javax.jms.IllegalStateException: Cannot find session with id r7-lczp85uf-1-hjjm85uf-wxb1yo-f1rp1a
               at org.jboss.jms.server.endpoint.ServerConnectionEndpoint.processTransaction(ServerConnectionEndpoint.java:835)
               at org.jboss.jms.server.endpoint.ServerConnectionEndpoint.sendTransaction(ServerConnectionEndpoint.java:497)
              
              ..stacktrace snipped...
              2009-04-30 19:15:11,619 WARN [com.arjuna.ats.jta.logging.loggerI18N] [com.arjuna.ats.internal.jta.resources.arjunacore.preparefailed] [com.arjuna.ats.internal.jta.resources.arjunacore.preparefailed] XAResourceRecord.prepare - prepare failed with exception XAException.XA_RETRY
              2009-04-30 19:15:11,619 WARN [com.arjuna.ats.arjuna.logging.arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.BasicAction_50] - Prepare phase of action a3d1b33:c3e:49f96bb1:6f received heuristic decision: TwoPhaseOutcome.HEURISTIC_HAZARD
              2009-04-30 19:15:11,619 WARN [com.arjuna.ats.arjuna.logging.arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.BasicAction_36] - BasicAction.End() - prepare phase of action-id a3d1b33:c3e:49f96bb1:6f failed.
              2009-04-30 19:15:11,619 WARN [com.arjuna.ats.arjuna.logging.arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.BasicAction_37] - Received heuristic: TwoPhaseOutcome.HEURISTIC_HAZARD .
              


              Is this still a JMS problem or should I be asking in the JTA forum?

              Thanks heaps,
              Len

              • 4. Re: Porting WLS8.1 to JBoss5 - JNDI lookup for XA factory re
                Len Walter Newbie

                Perhaps I should ask a different question - where's a good place to find doco that might help out here? I'm not a J2EE expert either (in case it wasn't obvious!) so perhaps I need to learn some more general stuff about that to solve these kind of problems.

                • 5. Re: Porting WLS8.1 to JBoss5 - JNDI lookup for XA factory re
                  Yong Hao Gao Master

                  Have you downloaded and read the AS documents from jboss.org? It should be a good thing to start with.

                  • 6. Re: Porting WLS8.1 to JBoss5 - JNDI lookup for XA factory re
                    Len Walter Newbie

                    I've read the config & admin document for AS, the JBM doco and the JTM doco. However I wasn't able to find any solutions.

                    NB that this code works fine in Weblogic 8.1, so you could classify this as a migration problem.