14 Replies Latest reply on May 21, 2004 9:42 AM by Adrian Brock

    Invalid Transaction ID Error

    Lyndon Livingstone Newbie

      The following stack trace is from a BEA WebLogic JMS Client attempting to produce a message on a JBossMQ Topic using XA. I am using JBoss 3.2.3 and BEA WebLogic 8.1 SP2.

      Any insight would help me enormously. Thank you.

      javax.jms.JMSException: Invalid transaction id.
      at org.jboss.mq.SpyXAResourceManager.addMessage(SpyXAResourceManager.java:95)
      at org.jboss.mq.SpySession.sendMessage(SpySession.java:728)
      at org.jboss.mq.SpyTopicPublisher.internalPublish(SpyTopicPublisher.java:120)
      at org.jboss.mq.SpyTopicPublisher.publish(SpyTopicPublisher.java:68)
      at weblogic.jms.adapter.JMSBaseConnection.sendInternal(JMSBaseConnection.java:704)
      at weblogic.jms.adapter.JMSBaseConnection.access$200(JMSBaseConnection.java:80)
      at weblogic.jms.adapter.JMSBaseConnection$6.run(JMSBaseConnection.java:645)
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
      at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
      at weblogic.jms.adapter.JMSBaseConnection.send(JMSBaseConnection.java:642)
      at weblogic.jms.adapter.JMSConnectionHandle.send(JMSConnectionHandle.java:140)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at weblogic.connector.common.internal.ConnectionWrapper.invoke(ConnectionWrapper.java:149)
      at $Proxy8.send(Unknown Source)
      at weblogic.jms.bridge.internal.MessagingBridge.processMessages(MessagingBridge.java:1362)
      at weblogic.jms.bridge.internal.MessagingBridge.beginForwarding(MessagingBridge.java:927)
      at weblogic.jms.bridge.internal.MessagingBridge.execute(MessagingBridge.java:1005)
      at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
      at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)

        • 1. Re: Invalid Transaction ID Error
          Adrian Brock Master

          The XASession's XAResource has not been enlisted in a JTA transaction.

          I recently added code for jboss-3.2.4 that allows JBossMQ's XAConnectionFactory
          to be used outside a JTA transaction (it behaves the same as AUTO_ACKNOWLEDGE)

          I would suggest you try it with the plain ConnectionFactory

          Or figure out why JBoss's session is not getting enlisted in the transaction
          by weblogic - probably because you are not using a conneciton factory
          that is proxied through welogic's (or jboss's) jms resource adapter.

          • 2. Re: Invalid Transaction ID Error
            Lyndon Livingstone Newbie

            Is this change in JBoss 3.2.4RC1 available from sourceforge?

            Thanks,

            Lyndon.

            • 3. Re: Invalid Transaction ID Error
              Adrian Brock Master

              No it is in 3.2.4RC2, due out any second now.

              • 4. Re: Invalid Transaction ID Error
                Lyndon Livingstone Newbie

                I decided to use the Connection Factory instead of the XAConnectionFactory. I now get a little further. Instead of only seeing an exception at the client I now also see one at the server. It is:

                java.lang.NullPointerException
                at org.jboss.mq.security.ServerSecurityInterceptor.addMessage(ServerSecurityInterceptor.java:158)
                at org.jboss.mq.server.TracingInterceptor.addMessage(TracingInterceptor.java:270)
                at org.jboss.mq.server.JMSServerInvoker.addMessage(JMSServerInvoker.java:136)
                at org.jboss.mq.il.oil.OILServerILService$Client.run(OILServerILService.java:249)
                at java.lang.Thread.run(Thread.java:536)

                I tried disabling the security manager but I get another null pointer exception in DestinationManager.addMessage().

                From looking at source, it seems as though the problem:

                String dest = ((SpyDestination)message.getJMSDestination()).getName();

                Thank you,

                Lyndon.

                • 5. Re: Invalid Transaction ID Error
                  Lyndon Livingstone Newbie

                  A little more stack trace. BTW. I am also pursuing this issue from the BEA side with BEA support.

                  org.jboss.mq.SpyJMSException: Cannot send a message to the JMS server; - nested throwable: (java.lang.NullPointerException)
                  at org.jboss.mq.Connection.sendToServer(Connection.java:1251)
                  at org.jboss.mq.SpySession.sendMessage(SpySession.java:732)
                  at org.jboss.mq.SpyTopicPublisher.internalPublish(SpyTopicPublisher.java:120)
                  at org.jboss.mq.SpyTopicPublisher.publish(SpyTopicPublisher.java:68)
                  at weblogic.jms.adapter.JMSBaseConnection.sendInternal(JMSBaseConnection.java:704)
                  at weblogic.jms.adapter.JMSBaseConnection.access$200(JMSBaseConnection.java:80)
                  at weblogic.jms.adapter.JMSBaseConnection$6.run(JMSBaseConnection.java:645)
                  at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
                  at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
                  at weblogic.jms.adapter.JMSBaseConnection.send(JMSBaseConnection.java:642)
                  at weblogic.jms.adapter.JMSConnectionHandle.send(JMSConnectionHandle.java:140)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at java.lang.reflect.Method.invoke(Method.java:324)
                  at weblogic.connector.common.internal.ConnectionWrapper.invoke(ConnectionWrapper.java:149)
                  at $Proxy9.send(Unknown Source)
                  at weblogic.jms.bridge.internal.MessagingBridge.onMessageInternal(MessagingBridge.java:1239)
                  at weblogic.jms.bridge.internal.MessagingBridge.onMessage(MessagingBridge.java:1163)
                  at weblogic.jms.adapter.JMSBaseConnection$27.run(JMSBaseConnection.java:1933)
                  at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
                  at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
                  at weblogic.jms.adapter.JMSBaseConnection.onMessage(JMSBaseConnection.java:1929)
                  at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:2596)
                  at weblogic.jms.client.JMSSession.execute(JMSSession.java:2516)
                  at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
                  at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
                  Caused by: java.lang.NullPointerException
                  at org.jboss.mq.security.ServerSecurityInterceptor.addMessage(ServerSecurityInterceptor.java:158)
                  at org.jboss.mq.server.TracingInterceptor.addMessage(TracingInterceptor.java:270)
                  at org.jboss.mq.server.JMSServerInvoker.addMessage(JMSServerInvoker.java:136)
                  at org.jboss.mq.il.oil.OILServerILService$Client.run(OILServerILService.java:249)
                  at java.lang.Thread.run(Thread.java:536)

                  • 6. Re: Invalid Transaction ID Error
                    Adrian Brock Master

                    If you can download 3.2.4RC2, that will give you a starting point.
                    Then modify this class to remove the wrapping mechanism when extending
                    external messages.

                    http://cvs.sourceforge.net/viewcvs.py/jboss/jbossmq/src/main/org/jboss/mq/SpyMessageProducer.java?annotate=1.2.8.2

                    i.e. in the method encapsulateMessage(...)
                    remove the block that begins
                    if (message instanceof Serializable)
                    {
                    ...
                    }

                    I have tested the fallback method for non serializable external messages.
                    It is also similar to the processing done by the MDB's DLQ.

                    The SpyEncapsulatedMessage method has obviously never been
                    tested with a transaction (it does not work because it nulls the destination when it
                    clones the message).

                    • 7. Re: Invalid Transaction ID Error
                      Lyndon Livingstone Newbie

                      As you suggested I used 3.2.4RC2 and modified the SpyMessageProducer class. The only change was that I now had to include the class of my object message in the classpath or else I got a class not found error in the encapsulate message method. After including the message object class in the classpath I recieved the same null pointer exception in the addMessage() method of the security interceptor as shown in the above posts 4 and 5.

                      I attempted sending text messages also and got the same result.

                      Do you have any other suggestions I could try?

                      I really appreciate your responses, thank you very much.

                      Lyndon.

                      • 8. Re: Invalid Transaction ID Error
                        Lyndon Livingstone Newbie

                        BTW, I also tried using the XAConnectionFactory and while I didn't get the invalid transaction ID, there was still some type of exception.

                        I am now only using the regular ConnectionFactory in my tests from my last post.

                        • 9. Re: Invalid Transaction ID Error
                          Adrian Brock Master

                          There is obviously something very peculiar about the WebLogic message
                          implementation.

                          Try it with these method implementations (which are probably more logical)
                          it no longer tries to set the destination on the WebLogic message then
                          copy it into the SpyMessage, instead it copies the WebLogic message first:

                           public void send(Destination destination, Message message, int deliveryMode, int priority, long ttl)
                           throws JMSException
                           {
                           checkClosed();
                          
                           if (this.destination != null && this.destination.equals(destination) == false)
                           throw new UnsupportedOperationException("Sending to " + destination
                           + " not allowed when producer created with " + this.destination);
                          
                           if (destination == null || (destination instanceof SpyDestination) == false)
                           throw new InvalidDestinationException("Destination is not an instance of SpyDestination " + destination);
                          
                           // Encapsulate the message if not a SpyMessage
                           if ((message instanceof SpyMessage) == false)
                           message = encapsulateMessage(message);
                          
                           //Set the header fields
                           message.setJMSDestination(destination);
                           message.setJMSDeliveryMode(deliveryMode);
                           long ts = System.currentTimeMillis();
                           message.setJMSTimestamp(ts);
                           if (ttl == 0)
                           message.setJMSExpiration(0);
                           else
                           message.setJMSExpiration(ttl + ts);
                           message.setJMSPriority(priority);
                           message.setJMSMessageID(session.getNewMessageID());
                          
                           if (trace)
                           log.trace("Sending message " + this + " \n" + message);
                          
                           //Send the message.
                           session.sendMessage((SpyMessage) message);
                           }
                          


                           protected SpyMessage encapsulateMessage(Message message) throws JMSException
                           {
                           SpyMessage result;
                           if (message instanceof BytesMessage)
                           {
                           result = MessagePool.getBytesMessage();
                           BytesMessage original = (BytesMessage) message;
                           original.reset();
                           byte[] temp = new byte[1024];
                           int bytes = original.readBytes(temp);
                           while (bytes != -1)
                           {
                           ((BytesMessage) result).writeBytes(temp, 0, bytes);
                           bytes = original.readBytes(temp);
                           }
                           }
                           else if (message instanceof MapMessage)
                           {
                           result = MessagePool.getMapMessage();
                           MapMessage original = (MapMessage) message;
                           for (Enumeration en=original.getMapNames(); en.hasMoreElements();)
                           {
                           String key = (String) en.nextElement();
                           try
                           {
                           ((MapMessage) result).setObject(key, original.getObject(key));
                           }
                           catch (JMSException ignored)
                           {
                           if (trace)
                           log.trace("Unable to copy map entry " + key, ignored);
                           }
                           }
                           }
                           else if (message instanceof StreamMessage)
                           {
                           result = MessagePool.getStreamMessage();
                           StreamMessage original = (StreamMessage) message;
                           original.reset();
                           try
                           {
                           while (true)
                           {
                           ((StreamMessage) result).writeObject(original.readObject());
                           }
                           }
                           catch (MessageEOFException expected)
                           {
                           }
                           }
                           else if (message instanceof ObjectMessage)
                           {
                           result = MessagePool.getObjectMessage();
                           ((ObjectMessage) result).setObject(((ObjectMessage) message).getObject());
                           }
                           else if (message instanceof TextMessage)
                           {
                           result = MessagePool.getTextMessage();
                           ((TextMessage) result).setText(((TextMessage) message).getText());
                           }
                           else
                           result = MessagePool.getMessage();
                          
                           // Copy headers
                           try
                           {
                           result.setJMSCorrelationID(message.getJMSCorrelationID());
                           }
                           catch (JMSException e)
                           {
                           //must be as bytes
                           result.setJMSCorrelationIDAsBytes(message.getJMSCorrelationIDAsBytes());
                           }
                           result.setJMSReplyTo(message.getJMSReplyTo());
                           result.setJMSType(message.getJMSType());
                          
                           // Copy properties
                           for (Enumeration en=message.getPropertyNames(); en.hasMoreElements();)
                           {
                           String key = (String) en.nextElement();
                           try
                           {
                           result.setObjectProperty(key, message.getObjectProperty(key));
                           }
                           catch (JMSException ignored)
                           {
                           if (trace)
                           log.trace("Unable to copy property " + key, ignored);
                           }
                           }
                          
                           return result;
                           }
                          


                          If that fails can you PLEASE post the full exceptions or some TRACE logging,
                          not "IT DOES NOT WORK".
                          I don't know how you expect to me to help you with such weak feedback?

                          • 10. Re: Invalid Transaction ID Error
                            Lyndon Livingstone Newbie

                            I have not yet tried out your last suggestion but here is a trace after trying the previous suggestion.

                            Here is a snippet from server.log with Tracing on for org.jboss.mq category.

                            2004-05-19 09:34:13,701 TRACE [org.jboss.mq.server.TracingInterceptor] CALLED : addMessage
                            2004-05-19 09:34:13,701 TRACE [org.jboss.mq.server.TracingInterceptor] ARG : SpyTextMessage {
                            Header {
                            jmsDestination : null
                            jmsDeliveryMode : 2
                            jmsExpiration : 0
                            jmsPriority : 4
                            jmsMessageID : ID:18-10849743965971
                            jmsTimeStamp : 1084973830032
                            jmsCorrelationID: null
                            jmsReplyTo : null
                            jmsType : null
                            jmsRedelivered : true
                            jmsProperties : {}
                            jmsPropReadWrite: true
                            msgReadOnly : false
                            producerClientId: ID:18
                            }
                            Body {
                            text :Hello World
                            }
                            }
                            2004-05-19 09:34:13,701 TRACE [org.jboss.mq.server.TracingInterceptor] EXCEPTION : addMessage:
                            java.lang.NullPointerException
                            at org.jboss.mq.security.ServerSecurityInterceptor.addMessage(ServerSecurityInterceptor.java:158)
                            at org.jboss.mq.server.TracingInterceptor.addMessage(TracingInterceptor.java:279)
                            at org.jboss.mq.server.JMSServerInvoker.addMessage(JMSServerInvoker.java:136)
                            at org.jboss.mq.il.oil.OILServerILService$Client.run(OILServerILService.java:242)
                            at java.lang.Thread.run(Thread.java:536)
                            2004-05-19 09:34:13,701 TRACE [org.jboss.mq.server.TracingInterceptor] RETURN : addMessage
                            2004-05-19 09:34:13,701 WARN [org.jboss.mq.il.oil.OILServerILService] Client request resulted in a server exception:
                            java.lang.NullPointerException
                            at org.jboss.mq.security.ServerSecurityInterceptor.addMessage(ServerSecurityInterceptor.java:158)
                            at org.jboss.mq.server.TracingInterceptor.addMessage(TracingInterceptor.java:279)
                            at org.jboss.mq.server.JMSServerInvoker.addMessage(JMSServerInvoker.java:136)
                            at org.jboss.mq.il.oil.OILServerILService$Client.run(OILServerILService.java:242)
                            at java.lang.Thread.run(Thread.java:536)

                            I will provide you whatever feedback you require, I'm just not sure what is helpful and what isn't. There is more logging, but the rest of server.log looks fine.

                            Regards,

                            Lyndon.

                            • 11. Re: Invalid Transaction ID Error
                              Lyndon Livingstone Newbie

                              Hi,

                              We are still doing testing, but initial assessment looks like your latest changes have solved the problem.

                              We were able to use the ConnectionFactory to publish a text message from the WebLogic Bridge to JBoss. The message was received by our MDB.

                              Your help was great. I hope that this new version of SpyMessageProducer will be included in 3.2.4. Please let me know if you plan to do this.

                              My next task will be to publish from WebLogic using the JBoss XAConnectionFactory. But I will deal with that when the time comes.

                              Again,

                              Thanks for your help. You have saved the few remaining patches of my hair from being ripped out.

                              Regards,

                              Lyndon

                              • 12. Re: Invalid Transaction ID Error
                                Adrian Brock Master

                                Yes, I will add it for 3.2.4 (after some testing of my own).

                                Let me know how the XA tests go.

                                • 13. Re: Invalid Transaction ID Error
                                  Lyndon Livingstone Newbie

                                  Do you know when the next build of 3.2.4 will be? I would prefer using your build rather than my hacked build.

                                  Regards,

                                  Lyndon.

                                  • 14. Re: Invalid Transaction ID Error
                                    Adrian Brock Master

                                    Arghh! I've already shouted people for continually asking this question.
                                    Use search.

                                    The answer is early next month.