Announcement Announcement Module
Collapse
No announcement yet.
"Transaction Propagation 'Requires New' causing proble Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • "Transaction Propagation 'Requires New' causing proble

    Hi,
    I am using JBoss 4.0.1 sp 1 with Spring 1.2.5. I am using JTA for managing transaction (as i am using both JDBC and JMS in same transaction). And due to some reasons i am using programmatic transaction management. My transaction manager configuration is as follows:

    Code:
    <!-- JNDI DataSource for J2EE environments -->
      <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName"><value>$&#123;db.jndiname&#125;</value></property>
      </bean>
    
      <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">    
        <property name="transactionManagerName"><value>java&#58;/TransactionManager</value></property>
      </bean>
    Now in one of my use cases a class initiaes a transaction with 'Required' as propagation level. Inside this transaction it has to start a new transaction (independent of first one) with Propagation level set to "Requires New". Now i got exceptions in JBoss.

    Code:
    2005-10-08 14&#58;59&#58;17,875 WARN  &#91;org.jboss.resource.connectionmanager.TxConnectionManager&#93; in Enlisting tx, trying to change tx. illegal state&#58; old&#58; TransactionImpl&#58;XidImpl&#91;FormatId=257, GlobalId=shoaib/7209, BranchQual=, localId=7209&#93;, new&#58; TransactionImpl&#58;XidImpl&#91;FormatId=257, GlobalId=shoaib/7328, BranchQual=, localId=7328&#93;, cel&#58; org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener@ca425c&#91;state=NORMAL mc=[email protected]ac handles=1 lastUse=1128765557328 permit=true trackByTx=true mcp=org.jboss.resource.connectionmanager.JBossManagedConnectionPool$OnePool@11ec5ee context=org.jboss.resource.connectionmanager.InternalManagedConnectionPool@154a573&#93;
    java.lang.IllegalStateException&#58; Trying to change Tx in enlist!
    	at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.enlist&#40;TxConnectionManager.java&#58;419&#41;
    	at org.jboss.resource.connectionmanager.TxConnectionManager.transactionStarted&#40;TxConnectionManager.java&#58;314&#41;
    	at org.jboss.resource.connectionmanager.CachedConnectionManager.userTransactionStarted&#40;CachedConnectionManager.java&#58;392&#41;
    	at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.begin&#40;ServerVMClientUserTransaction.java&#58;113&#41;
    	at org.springframework.transaction.jta.JtaTransactionManager.doJtaBegin&#40;JtaTransactionManager.java&#58;665&#41;
    	at org.springframework.transaction.jta.JtaTransactionManager.doBegin&#40;JtaTransactionManager.java&#58;623&#41;
    	at org.springframework.transaction.support.AbstractPlatformTransactionManager.handleExistingTransaction&#40;AbstractPlatformTransactionManager.java&#58;320&#41;
    	at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction&#40;AbstractPlatformTransactionManager.java&#58;262&#41;
    	at org.springframework.transaction.support.TransactionTemplate.execute&#40;TransactionTemplate.java&#58;111&#41;
    	at com.inov8.mpdf.server.receivemodule.service.TicketBufferService.loadBuffer&#40;TicketBufferService.java&#58;53&#41;
    	at com.inov8.mpdf.server.receivemodule.service.TicketBufferService.getTicket&#40;TicketBufferService.java&#58;112&#41;
    	at com.inov8.mpdf.server.receivemodule.service.TicketService.getTicketsBySMS&#40;TicketService.java&#58;38&#41;
    	at com.inov8.mpdf.server.receivemodule.service.ReceiverManagerService.getTicketForReceivedMessage&#40;ReceiverManagerService.java&#58;179&#41;
    	at com.inov8.mpdf.server.receivemodule.service.ReceiverManagerService.access$100&#40;ReceiverManagerService.java&#58;19&#41;
    	at com.inov8.mpdf.server.receivemodule.service.ReceiverManagerService$1.doInTransactionWithoutResult&#40;ReceiverManagerService.java&#58;95&#41;
    	at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction&#40;TransactionCallbackWithoutResult.java&#58;33&#41;
    	at org.springframework.transaction.support.TransactionTemplate.execute&#40;TransactionTemplate.java&#58;114&#41;
    	at com.inov8.mpdf.server.receivemodule.service.ReceiverManagerService.processReceivedMessage&#40;ReceiverManagerService.java&#58;84&#41;
    	at com.inov8.mpdf.server.receivemodule.ejb.mdb.ReceiveMDBBean.onMessage&#40;ReceiveMDBBean.java&#58;52&#41;
    	at sun.reflect.GeneratedMethodAccessor67.invoke&#40;Unknown Source&#41;
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;DelegatingMethodAccessorImpl.java&#58;25&#41;
    	at java.lang.reflect.Method.invoke&#40;Method.java&#58;585&#41;
    	at org.jboss.invocation.Invocation.performCall&#40;Invocation.java&#58;345&#41;
    	at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke&#40;MessageDrivenContainer.java&#58;475&#41;
    	at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke&#40;CachedConnectionInterceptor.java&#58;185&#41;
    	at org.jboss.ejb.plugins.CallValidationInterceptor.invoke&#40;CallValidationInterceptor.java&#58;48&#41;
    	at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext&#40;AbstractTxInterceptor.java&#58;105&#41;
    	at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext&#40;AbstractTxInterceptorBMT.java&#58;153&#41;
    	at org.jboss.ejb.plugins.MessageDrivenTxInterceptorBMT.invoke&#40;MessageDrivenTxInterceptorBMT.java&#58;32&#41;
    	at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke&#40;MessageDrivenInstanceInterceptor.java&#58;87&#41;
    	at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke&#40;RunAsSecurityInterceptor.java&#58;94&#41;
    	at org.jboss.ejb.plugins.LogInterceptor.invoke&#40;LogInterceptor.java&#58;192&#41;
    	at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke&#40;ProxyFactoryFinderInterceptor.java&#58;122&#41;
    	at org.jboss.ejb.MessageDrivenContainer.internalInvoke&#40;MessageDrivenContainer.java&#58;389&#41;
    	at org.jboss.ejb.Container.invoke&#40;Container.java&#58;870&#41;
    	at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke&#40;JMSContainerInvoker.java&#58;967&#41;
    	at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage&#40;JMSContainerInvoker.java&#58;1253&#41;
    	at org.jboss.jms.asf.StdServerSession.onMessage&#40;StdServerSession.java&#58;256&#41;
    	at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage&#40;SpyMessageConsumer.java&#58;904&#41;
    	at org.jboss.mq.SpyMessageConsumer.addMessage&#40;SpyMessageConsumer.java&#58;159&#41;
    	at org.jboss.mq.SpySession.run&#40;SpySession.java&#58;351&#41;
    	at org.jboss.jms.asf.StdServerSession.run&#40;StdServerSession.java&#58;180&#41;
    	at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run&#40;PooledExecutor.java&#58;748&#41;
    	at java.lang.Thread.run&#40;Thread.java&#58;595&#41;
    I am using programmatic transactions in this way
    The Bigger transaction is
    Code:
     TransactionTemplate transactionTemplate = new TransactionTemplate&#40;this.
            transactionManager&#41;;
        transactionTemplate.setPropagationBehavior&#40;TransactionDefinition.
                                                   PROPAGATION_REQUIRED&#41;;
        transactionTemplate.execute&#40;new TransactionCallbackWithoutResult&#40;&#41;
        &#123;
          public void doInTransactionWithoutResult&#40;TransactionStatus status&#41;
          &#123;
              // My code goes here
          &#125;&#41;;
    &#123;
    and the inner transaction uses code like this
    Code:
     TransactionTemplate transactionTemplate = new TransactionTemplate&#40;this.
            transactionManager&#41;;
        transactionTemplate.setPropagationBehavior&#40;TransactionDefinition.PROPAGATION_REQUIRES_NEW&#41;;
        transactionTemplate.execute&#40;new TransactionCallbackWithoutResult&#40;&#41;
        &#123;
          public void doInTransactionWithoutResult&#40;TransactionStatus status&#41;
          &#123;
              // My code goes here
          &#125;&#41;;
    &#125;
    Not related to this issue but while profiling my code i saw that most of the time was wasting in Debug statement. And major culprit was Spring instead of using
    Code:
    if&#40;logger.isDebugEnabled&#40;&#41;
    &#123;
     logger.debug&#40;"dfd"&#41;;
    &#125;
    it was doing
    Code:
     logger.debug&#40;"dfd"&#41;;
    So even switching off logging was not helping ( i raised it to FataL) but spring was taking too much time dure to above mentioned issue.

    So please can anybody help me reagrding Transaction issue.

  • #2
    Unfortunately, I have never seen that JBoss transaction failure before... Not sure what the cause of that could be.

    Regarding the debug logging: I have just re-checked that Spring's transaction package always uses isDebugEnabled() checks where it makes sense. Note that it doesn't make sense to use isDebugEnabled() checks for "logger.debug" calls with plain argument references: isDebugEnabled() only adds value for calls where an argument is built through String concatenation or other expensive operations.

    Juergen

    Comment


    • #3
      Hi,
      Thanks Juergen for your reply. But i am afraid this is not a solution of my problem. I will highly appreciate if you could dig a bit deeper to solve it. First,
      i was using Last Resource Gambit (LLR) and not using Oracle XA drivers in distributed transaction (i told earlier that i am using JMS too). Now to just make it sure i converted to Oracle XA drivers but to no avail and still the same very exceptions are coming. Although, i am using TransactinManager instead of UserTransaction ( so that suspend and resume can work for programmatic transaction management) but still the problem is coming . Could it be so that Spring is trying to use the same connection in inner transaction as used in the outer transaction.... so might be the message coming that already enlist. I would highly appreciate if you could find any solution for me. Please help me asap.

      Comment


      • #4
        Hi,
        This is my log when the outer transaction is suspended and new one is started.
        Code:
        2005-10-10 13&#58;04&#58;57,906 DEBUG &#91;org.springframework.transaction.jta.JtaTransactionManager&#93; Using transaction object &#91;org.springframework.transaction.jta.JtaTransactionObject@18db7ce&#93;
        2005-10-10 13&#58;04&#58;57,906 DEBUG &#91;org.springframework.transaction.jta.JtaTransactionManager&#93; Suspending current transaction, creating new transaction with name &#91;null&#93;
        2005-10-10 13&#58;04&#58;57,906 DEBUG &#91;org.springframework.transaction.jta.JtaTransactionManager&#93; Suspending JTA transaction
        2005-10-10 13&#58;04&#58;57,906 DEBUG &#91;org.springframework.transaction.support.TransactionSynchronizationManager&#93; Removed value &#91;org.springframework.jdbc.datasource.ConnectionHolder@b8d335&#93; for key &#91;org.jboss.resource.adapter.jdbc.WrapperDataSource@777255&#93; from thread &#91;JMS SessionPool Worker-0&#93;
        2005-10-10 13&#58;04&#58;57,906 DEBUG &#91;org.springframework.transaction.support.TransactionSynchronizationManager&#93; Clearing transaction synchronization
        2005-10-10 13&#58;04&#58;57,906 DEBUG &#91;org.springframework.transaction.jta.JtaTransactionManager&#93; Beginning JTA transaction
        2005-10-10 13&#58;04&#58;57,906 WARN  &#91;org.jboss.resource.connectionmanager.TxConnectionManager&#93; in Enlisting tx, trying to change tx. illegal state&#58; old&#58; TransactionImpl&#58;XidImpl&#91;FormatId=257, GlobalId=shoaib/44, BranchQual=, localId=44&#93;, new&#58; TransactionImpl&#58;XidImpl&#91;FormatId=257, GlobalId=shoaib/45, BranchQual=, localId=45&#93;, cel&#58; org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener@dddff&#91;state=NORMAL mc=org.jboss.resource.adapter.jdbc.xa.XAManagedConnection@11e3c55 handles=1 lastUse=1128931439078 permit=true trackByTx=true mcp=org.jboss.resource.connectionmanager.JBossManagedConnectionPool$OnePool@b1b14 context=org.jboss.resource.connectionmanager.InternalManagedConnectionPool@11ef262&#93;
        So seeing this log it seems to me that like in Weblogic case (which is solved now i think by using soemthing force or whatsoever)... there are also some problems exists in case of JBoss Application Server (4.0.1 sp1) which prevents suspending and then starting new transaction properly. Also please keep into mind that i am staring a new Transaction (Rquires_new) inside of a transaction with (Required) so suspending and then resuming should work fine.I guess you people can look into this better than me. I will be highly obliged if you could give me amy answer.

        Comment


        • #5
          In order to speed this up - could you try to do the same thing without using the Spring transaction management. There is an article on onjava.com that outlines how to do this - http://www.onjava.com/pub/a/onjava/2...nsactions.html

          That way we will know whether to look for a Spring issue or whether we have to add some code to work around an appserver issue.

          Comment


          • #6
            Hi,
            What a coincidence Mr. Trisberg, yesterday night i also tried the same example just to make sure that where problem lies. But alas the example you mentioned ran successfully without giving any error whatsoever ( I did not check it on my code rather copied the example code). I think that you people should look into this because as soon spring call the Jboss method to initiate new transaction it gives the error. But in case of that example there is no problem at all. Hoping that you will help me soon as our product is Spring Based and we are going to launch it at the end of this week. I will be highly grateful if you people can look into this. Anyways i am Spring maniac.

            Comment


            • #7
              Hi,
              Today morning i modified my code accoeding to the example as well and used UserTransaction and Transaction manager directly without using Spring abstraction. It worked perfectly well without any sort of error what so ever. So now i am getting pretty much sure that spring is the culprit here and something is missing in JBoss case (in transaction suspension and starting new one part). I hope that you people can solve it bit earlier. Just for refernce i am pasting my code as done in that onjava example case it worked perfectly well.

              Outer Transaction Code
              Code:
              public void processReceivedMessage&#40;final ReceivedMessage receivedMessage&#41;
                &#123;
                  UserTransaction userTransaction = null;
                  try
                  &#123;
                    InitialContext ctx = new InitialContext&#40;&#41;;
                    userTransaction = &#40;UserTransaction&#41; ctx.lookup&#40;"java&#58;comp/UserTransaction"&#41;;
                    userTransaction.begin&#40;&#41;;
                    boolean retry = true;
                    while &#40;retry&#41;
                    &#123;
                      try
                      &#123;
                        long startTime = System.currentTimeMillis&#40;&#41;;
                        insertIntoLogReceiveData&#40;receivedMessage&#41;;
                        ArrayList<SendMessage> sendMessageList = getTicketForReceivedMessage&#40;receivedMessage&#41;;
                        long endTime = System.currentTimeMillis&#40;&#41;;
                        if &#40;logger.isDebugEnabled&#40;&#41;&#41;
                        &#123;
                          logger.debug&#40;"Database Access in Receive took&#58; " + &#40;endTime - startTime&#41;&#41;;
                        &#125;
                        jmsSender.insertToSendDestination&#40;sendMessageList&#41;;
                        retry = false;
                        userTransaction.commit&#40;&#41;;
                      &#125;
                      catch &#40;NoTicketAvailableException noTicketAvailableException&#41;
                      &#123;
                        if &#40;logger.isWarnEnabled&#40;&#41;&#41;
                        &#123;
                          logger.warn&#40;"NoTicketAvailableException occurred.", noTicketAvailableException&#41;;
                        &#125;
                        userTransaction.setRollbackOnly&#40;&#41;;
                        notifier.notifyFailure&#40;INotifyScenerios.NO_TICKETS_AVAILABLE_FAILURE&#41;;
                        sleepThisThread&#40;&#41;;
                      &#125;
                      catch &#40;DataAccessException dataAccessException&#41;
                      &#123;
                        if &#40;logger.isWarnEnabled&#40;&#41;&#41;
                        &#123;
                          logger.warn&#40;"DataAccessException occurred in ReceiverManagerService",
                                      dataAccessException&#41;;
                        &#125;
                        userTransaction.setRollbackOnly&#40;&#41;;
                        notifier.notifyFailure&#40;INotifyScenerios.DB_CONNECTION_FAILURE&#41;;
                        sleepThisThread&#40;&#41;;
                      &#125;
                      catch &#40;JmsException jmsException&#41;
                      &#123;
                        if &#40;logger.isWarnEnabled&#40;&#41;&#41;
                        &#123;
                          logger.warn&#40;"JmsException occurred in ReceiverManagerService", jmsException&#41;;
                        &#125;
                        userTransaction.setRollbackOnly&#40;&#41;;
                        sleepThisThread&#40;&#41;;
                      &#125;
                      catch &#40;Exception ex&#41;
                      &#123;
                        if &#40;logger.isWarnEnabled&#40;&#41;&#41;
                        &#123;
                          logger.warn&#40;"Unknown Exception occurred in ReceiverManagerService", ex&#41;;
                        &#125;
                        userTransaction.setRollbackOnly&#40;&#41;;
                        notifier.notifyFailure&#40;INotifyScenerios.DB_CONNECTION_FAILURE&#41;;
                        sleepThisThread&#40;&#41;;
                      &#125;
                    &#125;
                  &#125;
                  catch &#40;Exception ex&#41;
                  &#123;
                    try
                    &#123;
                      userTransaction.setRollbackOnly&#40;&#41;;
                      ex.printStackTrace&#40;&#41;;
                    &#125;
                    catch &#40;Exception ex1&#41;
                    &#123;
                      ex1.printStackTrace&#40;&#41;;
                    &#125;
                  &#125;
              Inner Transacation Code
              Code:
               private void loadBuffer&#40;&#41;
                &#123;
                  UserTransaction userTransaction = null;
                  TransactionManager tm = null;
                  Transaction transaction = null;
                  try
                  &#123;
                    InitialContext ctx = new InitialContext&#40;&#41;;
                    userTransaction = &#40;UserTransaction&#41; ctx.lookup&#40;"java&#58;comp/UserTransaction"&#41;;
                    tm = getFromJNDI&#40;&#41;;
                    transaction = tm.suspend&#40;&#41;;
                    userTransaction.begin&#40;&#41;;
              
                    if &#40;getBufferSize&#40;&#41; == null&#41;
                    &#123;
                      throw new IllegalStateException&#40;
                          "The Buffer Size property should be set before loading the buffer."&#41;;
                    &#125;
                    bufferedTicketList = ticketBufferDAO.getBufferedTicketList&#40;getBufferSize&#40;&#41;, ipAddress,
                        APPLICATION_NAME&#41;;
              
                    if &#40;bufferedTicketList == null || bufferedTicketList.size&#40;&#41; == 0&#41;
                    &#123;
                      throw new NoTicketAvailableException&#40;"No more Tickets available"&#41;;
                    &#125;
                    userTransaction.commit&#40;&#41;;
                    tm.resume&#40;transaction&#41;;
                  &#125;
                  catch &#40;Throwable ex&#41;
                  &#123;
                    logger.fatal&#40;"Excpetion came while loading Buffer", ex&#41;;
                    try
                    &#123;
                      userTransaction.setRollbackOnly&#40;&#41;;
                    &#125;
                    catch &#40;Exception ex2&#41;
                    &#123;
                      ex2.printStackTrace&#40;&#41;;
                    &#125;
                    throw new NoTicketAvailableException&#40;ex&#41;;
                  &#125;
                &#125;
              Note: I also tried direct PlatformTransactionManager Usage (pg: 243 expert One on One: J2EE development without EJB ) but to no avail. So PlatformtransactionManager and TransactionTemplate both are not working for me.
              I just saw the code of JBoss where error is come
              The file is TxConnectionManager.java in JBoss 4.0.1 sp 1 source code.
              Code:
              if &#40;currentTx != null && currentTx.equals&#40;newCurrentTx&#41; == false&#41;
                          &#123;
                             log.warn&#40;"in Enlisting tx, trying to change tx. illegal state&#58; old&#58; " + currentTx + ", new&#58; " + newCurrentTx + ", cel&#58; " + this&#41;;
                             throw new IllegalStateException&#40;"Trying to change Tx in enlist!"&#41;;
                          &#125;
              Hope you guys can solve it a bit faster (only a request).

              Comment


              • #8
                Hi Guys,
                I am waiting for any kind of response from your side. Hope yo u can find it earlier.

                Comment


                • #9
                  Hi,
                  I made an other try which give me significant clue. I made a test application and step by step i take it towards my real application. I am using Message Driven Bean (with Bean Managed transaction) in my application that upon receiving a new JMS message send it to a Spring Managed POJO and there the outer transaction starts and then it calls another object (to load Lottery Ticket Buffer and which needs new independent transaction when buffer is empty) and there the inner transaction starts(with requires_New). Now i made a test app without Message Driven Bean and it was working fine with Spring and JBoss 4.0.1 sp1 but as soon i intoduce Message Driven bean as in my actual app it start giving error of Illegel State Exception. The stack trace is very much same as in previous post but with this modification at the end only

                  Please see the stack trace in previous posts too
                  Code:
                  2005-10-12 14&#58;08&#58;40,140 INFO  &#91;STDOUT&#93; java.lang.IllegalStateException&#58; Cannot deactivate transaction synchronization - not active
                  2005-10-12 14&#58;08&#58;40,140 INFO  &#91;STDOUT&#93; 	at org.springframework.transaction.support.TransactionSynchronizationManager.clearSynchronization&#40;TransactionSynchronizationManager.java&#58;257&#41;
                  2005-10-12 14&#58;08&#58;40,140 INFO  &#91;STDOUT&#93; 	at org.springframework.transaction.support.AbstractPlatformTransactionManager.cleanupAfterCompletion&#40;AbstractPlatformTransactionManager.java&#58;741&#41;
                  2005-10-12 14&#58;08&#58;40,140 INFO  &#91;STDOUT&#93; 	at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback&#40;AbstractPlatformTransactionManager.java&#58;610&#41;
                  2005-10-12 14&#58;08&#58;40,140 INFO  &#91;STDOUT&#93; 	at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback&#40;AbstractPlatformTransactionManager.java&#58;555&#41;
                  2005-10-12 14&#58;08&#58;40,140 INFO  &#91;STDOUT&#93; 	at org.springframework.transaction.support.TransactionTemplate.rollbackOnException&#40;TransactionTemplate.java&#58;141&#41;
                  2005-10-12 14&#58;08&#58;40,140 INFO  &#91;STDOUT&#93; 	at org.springframework.transaction.support.TransactionTemplate.execute&#40;TransactionTemplate.java&#58;118&#41;
                  2005-10-12 14&#58;08&#58;40,140 INFO  &#91;STDOUT&#93; 	at weblogictransactiontest.TestingTransactionService.requiresTransaction&#40;TestingTransactionService.java&#58;39&#41;
                  2005-10-12 14&#58;08&#58;40,156 INFO  &#91;STDOUT&#93; 	at weblogictransactiontest.TestingTransactionMDBBean.onMessage&#40;TestingTransactionMDBBean.java&#58;32&#41;
                  2005-10-12 14&#58;08&#58;40,156 INFO  &#91;STDOUT&#93; 	at sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Native Method&#41;
                  2005-10-12 14&#58;08&#58;40,156 INFO  &#91;STDOUT&#93; 	at sun.reflect.NativeMethodAccessorImpl.invoke&#40;NativeMethodAccessorImpl.java&#58;39&#41;
                  2005-10-12 14&#58;08&#58;40,156 INFO  &#91;STDOUT&#93; 	at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;DelegatingMethodAccessorImpl.java&#58;25&#41;
                  2005-10-12 14&#58;08&#58;40,156 INFO  &#91;STDOUT&#93; 	at java.lang.reflect.Method.invoke&#40;Method.java&#58;585&#41;
                  2005-10-12 14&#58;08&#58;40,156 INFO  &#91;STDOUT&#93; 	at org.jboss.invocation.Invocation.performCall&#40;Invocation.java&#58;345&#41;
                  2005-10-12 14&#58;08&#58;40,156 INFO  &#91;STDOUT&#93; 	at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke&#40;MessageDrivenContainer.java&#58;475&#41;
                  2005-10-12 14&#58;08&#58;40,156 INFO  &#91;STDOUT&#93; 	at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke&#40;CachedConnectionInterceptor.java&#58;185&#41;
                  2005-10-12 14&#58;08&#58;40,156 INFO  &#91;STDOUT&#93; 	at org.jboss.ejb.plugins.CallValidationInterceptor.invoke&#40;CallValidationInterceptor.java&#58;48&#41;
                  2005-10-12 14&#58;08&#58;40,156 INFO  &#91;STDOUT&#93; 	at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext&#40;AbstractTxInterceptor.java&#58;105&#41;
                  2005-10-12 14&#58;08&#58;40,171 INFO  &#91;STDOUT&#93; 	at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext&#40;AbstractTxInterceptorBMT.java&#58;153&#41;
                  2005-10-12 14&#58;08&#58;40,171 INFO  &#91;STDOUT&#93; 	at org.jboss.ejb.plugins.MessageDrivenTxInterceptorBMT.invoke&#40;MessageDrivenTxInterceptorBMT.java&#58;32&#41;
                  2005-10-12 14&#58;08&#58;40,171 INFO  &#91;STDOUT&#93; 	at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke&#40;MessageDrivenInstanceInterceptor.java&#58;87&#41;
                  2005-10-12 14&#58;08&#58;40,171 INFO  &#91;STDOUT&#93; 	at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke&#40;RunAsSecurityInterceptor.java&#58;94&#41;
                  2005-10-12 14&#58;08&#58;40,171 INFO  &#91;STDOUT&#93; 	at org.jboss.ejb.plugins.LogInterceptor.invoke&#40;LogInterceptor.java&#58;192&#41;
                  2005-10-12 14&#58;08&#58;40,171 INFO  &#91;STDOUT&#93; 	at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke&#40;ProxyFactoryFinderInterceptor.java&#58;122&#41;
                  2005-10-12 14&#58;08&#58;40,171 INFO  &#91;STDOUT&#93; 	at org.jboss.ejb.MessageDrivenContainer.internalInvoke&#40;MessageDrivenContainer.java&#58;389&#41;
                  2005-10-12 14&#58;08&#58;40,171 INFO  &#91;STDOUT&#93; 	at org.jboss.ejb.Container.invoke&#40;Container.java&#58;870&#41;
                  2005-10-12 14&#58;08&#58;40,171 INFO  &#91;STDOUT&#93; 	at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke&#40;JMSContainerInvoker.java&#58;967&#41;
                  2005-10-12 14&#58;08&#58;40,171 INFO  &#91;STDOUT&#93; 	at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage&#40;JMSContainerInvoker.java&#58;1253&#41;
                  2005-10-12 14&#58;08&#58;40,171 INFO  &#91;STDOUT&#93; 	at org.jboss.jms.asf.StdServerSession.onMessage&#40;StdServerSession.java&#58;256&#41;
                  2005-10-12 14&#58;08&#58;40,171 INFO  &#91;STDOUT&#93; 	at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage&#40;SpyMessageConsumer.java&#58;904&#41;
                  2005-10-12 14&#58;08&#58;40,171 INFO  &#91;STDOUT&#93; 	at org.jboss.mq.SpyMessageConsumer.addMessage&#40;SpyMessageConsumer.java&#58;159&#41;
                  2005-10-12 14&#58;08&#58;40,171 INFO  &#91;STDOUT&#93; 	at org.jboss.mq.SpySession.run&#40;SpySession.java&#58;351&#41;
                  2005-10-12 14&#58;08&#58;40,187 INFO  &#91;STDOUT&#93; 	at org.jboss.jms.asf.StdServerSession.run&#40;StdServerSession.java&#58;180&#41;
                  2005-10-12 14&#58;08&#58;40,187 INFO  &#91;STDOUT&#93; 	at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run&#40;PooledExecutor.java&#58;743&#41;
                  2005-10-12 14&#58;08&#58;40,187 INFO  &#91;STDOUT&#93; 	at java.lang.Thread.run&#40;Thread.java&#58;595&#41;
                  2005-10-12 14&#58;08&#58;40,187 INFO  &#91;org.jboss.resource.connectionmanager.CachedConnectionManager&#93; Closing a connection for you.  Please close them yourself&#58; org.jboss.resource.adapter.jdbc.WrappedConnection@221f81
                  java.lang.Exception&#58; STACKTRACE
                  	at org.jboss.resource.connectionmanager.CachedConnectionManager.registerConnection&#40;CachedConnectionManager.java&#58;320&#41;
                  	at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection&#40;BaseConnectionManager2.java&#58;477&#41;
                  	at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection&#40;BaseConnectionManager2.java&#58;838&#41;
                  	at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection&#40;WrapperDataSource.java&#58;102&#41;
                  	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection&#40;DataSourceUtils.java&#58;107&#41;
                  	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection&#40;DataSourceUtils.java&#58;77&#41;
                  	at org.springframework.jdbc.core.JdbcTemplate.execute&#40;JdbcTemplate.java&#58;240&#41;
                  	at org.springframework.jdbc.core.JdbcTemplate.query&#40;JdbcTemplate.java&#58;326&#41;
                  	at org.springframework.jdbc.core.JdbcTemplate.query&#40;JdbcTemplate.java&#58;330&#41;
                  	at org.springframework.jdbc.core.JdbcTemplate.query&#40;JdbcTemplate.java&#58;334&#41;
                  	at org.springframework.jdbc.core.JdbcTemplate.queryForObject&#40;JdbcTemplate.java&#58;342&#41;
                  	at org.springframework.jdbc.core.JdbcTemplate.queryForObject&#40;JdbcTemplate.java&#58;347&#41;
                  	at org.springframework.jdbc.core.JdbcTemplate.queryForInt&#40;JdbcTemplate.java&#58;356&#41;
                  	at weblogictransactiontest.TicketBufferDAO.test1&#40;TicketBufferDAO.java&#58;31&#41;
                  	at weblogictransactiontest.TestingTransactionService$2.doInTransactionWithoutResult&#40;TestingTransactionService.java&#58;44&#41;
                  	at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction&#40;TransactionCallbackWithoutResult.java&#58;33&#41;
                  	at org.springframework.transaction.support.TransactionTemplate.execute&#40;TransactionTemplate.java&#58;114&#41;
                  	at weblogictransactiontest.TestingTransactionService.requiresTransaction&#40;TestingTransactionService.java&#58;39&#41;
                  	at weblogictransactiontest.TestingTransactionMDBBean.onMessage&#40;TestingTransactionMDBBean.java&#58;32&#41;
                  	at sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Native Method&#41;
                  	at sun.reflect.NativeMethodAccessorImpl.invoke&#40;NativeMethodAccessorImpl.java&#58;39&#41;
                  	at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;DelegatingMethodAccessorImpl.java&#58;25&#41;
                  	at java.lang.reflect.Method.invoke&#40;Method.java&#58;585&#41;
                  	at org.jboss.invocation.Invocation.performCall&#40;Invocation.java&#58;345&#41;
                  	at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke&#40;MessageDrivenContainer.java&#58;475&#41;
                  	at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke&#40;CachedConnectionInterceptor.java&#58;185&#41;
                  	at org.jboss.ejb.plugins.CallValidationInterceptor.invoke&#40;CallValidationInterceptor.java&#58;48&#41;
                  	at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext&#40;AbstractTxInterceptor.java&#58;105&#41;
                  	at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext&#40;AbstractTxInterceptorBMT.java&#58;153&#41;
                  	at org.jboss.ejb.plugins.MessageDrivenTxInterceptorBMT.invoke&#40;MessageDrivenTxInterceptorBMT.java&#58;32&#41;
                  	at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke&#40;MessageDrivenInstanceInterceptor.java&#58;87&#41;
                  	at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke&#40;RunAsSecurityInterceptor.java&#58;94&#41;
                  	at org.jboss.ejb.plugins.LogInterceptor.invoke&#40;LogInterceptor.java&#58;192&#41;
                  	at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke&#40;ProxyFactoryFinderInterceptor.java&#58;122&#41;
                  	at org.jboss.ejb.MessageDrivenContainer.internalInvoke&#40;MessageDrivenContainer.java&#58;389&#41;
                  	at org.jboss.ejb.Container.invoke&#40;Container.java&#58;870&#41;
                  	at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke&#40;JMSContainerInvoker.java&#58;967&#41;
                  	at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage&#40;JMSContainerInvoker.java&#58;1253&#41;
                  	at org.jboss.jms.asf.StdServerSession.onMessage&#40;StdServerSession.java&#58;256&#41;
                  	at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage&#40;SpyMessageConsumer.java&#58;904&#41;
                  	at org.jboss.mq.SpyMessageConsumer.addMessage&#40;SpyMessageConsumer.java&#58;159&#41;
                  	at org.jboss.mq.SpySession.run&#40;SpySession.java&#58;351&#41;
                  	at org.jboss.jms.asf.StdServerSession.run&#40;StdServerSession.java&#58;180&#41;
                  	at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run&#40;PooledExecutor.java&#58;743&#41;
                  	at java.lang.Thread.run&#40;Thread.java&#58;595&#41;
                  2005-10-12 14&#58;08&#58;40,187 ERROR &#91;org.jboss.ejb.plugins.MessageDrivenTxInterceptorBMT&#93; Application error&#58; BMT stateless bean TestingTransactionMDB should complete transactions before returning &#40;ejb1.1 spec, 11.6.1&#41;
                  2005-10-12 14&#58;08&#58;40,250 ERROR &#91;org.jboss.ejb.plugins.jms.JMSContainerInvoker&#93; Exception in JMSCI message listener
                  javax.ejb.EJBException&#58; null; CausedByException is&#58;
                  	Application error&#58; BMT stateless bean TestingTransactionMDB should complete transactions before returning &#40;ejb1.1 spec, 11.6.1&#41;
                  	at org.jboss.ejb.plugins.LogInterceptor.handleException&#40;LogInterceptor.java&#58;411&#41;
                  	at org.jboss.ejb.plugins.LogInterceptor.invoke&#40;LogInterceptor.java&#58;196&#41;
                  	at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke&#40;ProxyFactoryFinderInterceptor.java&#58;122&#41;
                  	at org.jboss.ejb.MessageDrivenContainer.internalInvoke&#40;MessageDrivenContainer.java&#58;389&#41;
                  	at org.jboss.ejb.Container.invoke&#40;Container.java&#58;870&#41;
                  	at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke&#40;JMSContainerInvoker.java&#58;967&#41;
                  	at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage&#40;JMSContainerInvoker.java&#58;1253&#41;
                  	at org.jboss.jms.asf.StdServerSession.onMessage&#40;StdServerSession.java&#58;256&#41;
                  	at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage&#40;SpyMessageConsumer.java&#58;904&#41;
                  	at org.jboss.mq.SpyMessageConsumer.addMessage&#40;SpyMessageConsumer.java&#58;159&#41;
                  	at org.jboss.mq.SpySession.run&#40;SpySession.java&#58;351&#41;
                  	at org.jboss.jms.asf.StdServerSession.run&#40;StdServerSession.java&#58;180&#41;
                  	at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run&#40;PooledExecutor.java&#58;743&#41;
                  	at java.lang.Thread.run&#40;Thread.java&#58;595&#41;
                  java.rmi.RemoteException&#58; Application error&#58; BMT stateless bean TestingTransactionMDB should complete transactions before returning &#40;ejb1.1 spec, 11.6.1&#41;
                  	at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.checkStatelessDone&#40;AbstractTxInterceptorBMT.java&#58;208&#41;
                  	at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext&#40;AbstractTxInterceptorBMT.java&#58;157&#41;
                  	at org.jboss.ejb.plugins.MessageDrivenTxInterceptorBMT.invoke&#40;MessageDrivenTxInterceptorBMT.java&#58;32&#41;
                  	at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke&#40;MessageDrivenInstanceInterceptor.java&#58;87&#41;
                  	at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke&#40;RunAsSecurityInterceptor.java&#58;94&#41;
                  	at org.jboss.ejb.plugins.LogInterceptor.invoke&#40;LogInterceptor.java&#58;192&#41;
                  	at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke&#40;ProxyFactoryFinderInterceptor.java&#58;122&#41;
                  	at org.jboss.ejb.MessageDrivenContainer.internalInvoke&#40;MessageDrivenContainer.java&#58;389&#41;
                  	at org.jboss.ejb.Container.invoke&#40;Container.java&#58;870&#41;
                  	at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke&#40;JMSContainerInvoker.java&#58;967&#41;
                  	at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage&#40;JMSContainerInvoker.java&#58;1253&#41;
                  	at org.jboss.jms.asf.StdServerSession.onMessage&#40;StdServerSession.java&#58;256&#41;
                  	at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage&#40;SpyMessageConsumer.java&#58;904&#41;
                  	at org.jboss.mq.SpyMessageConsumer.addMessage&#40;SpyMessageConsumer.java&#58;159&#41;
                  	at org.jboss.mq.SpySession.run&#40;SpySession.java&#58;351&#41;
                  	at org.jboss.jms.asf.StdServerSession.run&#40;StdServerSession.java&#58;180&#41;
                  	at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run&#40;PooledExecutor.java&#58;743&#41;
                  	at java.lang.Thread.run&#40;Thread.java&#58;595&#41;
                  I also found a usefull link on JBoss Regarding a Bug (discarded) http://jira.jboss.com/jira/browse/JBAS-2080
                  Now can somebody tell me what to do. Due to certain reason i dont want CMT in Message driven bean and want to work with Spring Transaction abstarction.Please help me asap.

                  Comment


                  • #10
                    Have you tried a MessageDrivenBean using UserTransaction andTransactionManager from JNDI lookups without using Spring's transaction management? If that works fine then I will have to write some testcode to reproduce this error.

                    I just configured a JBoss 4.1sp1 environment so hopefully it will be fairly easy to reproduce this.

                    Comment


                    • #11
                      I just ran a test and I'm not seeing this issue. I'm of course not performing any real work so it might not be 100% comparable. Could you post the code taht you actually have in your doInTransaction callbacks?

                      Here is my log output:

                      Code:
                      12&#58;58&#58;03,401 DEBUG &#91;JtaTransactionManager&#93; Retrieving JTA TransactionManager from JNDI location &#91;java&#58;/TransactionManager&#93;
                      12&#58;58&#58;03,403 DEBUG &#91;JndiTemplate&#93; Looking up JNDI object with name &#91;java&#58;/TransactionManager&#93;
                      12&#58;58&#58;03,405 DEBUG &#91;JtaTransactionManager&#93; JTA TransactionManager found at fallback JNDI location &#91;java&#58;/TransactionManager&#93;
                      12&#58;58&#58;03,407 INFO  &#91;JtaTransactionManager&#93; Using JTA UserTransaction&#58; org.jboss.ejb.EnterpriseContext$UserTransactionImpl@2b6226
                      12&#58;58&#58;03,408 INFO  &#91;JtaTransactionManager&#93; Using JTA TransactionManager&#58; org.jboss.tm.TxManager@38d4e2
                      12&#58;58&#58;03,410 INFO  &#91;STDOUT&#93; *** Create TransactionTemplate
                      12&#58;58&#58;03,433 INFO  &#91;STDOUT&#93; *** Propagation=0
                      12&#58;58&#58;03,443 DEBUG &#91;JtaTransactionManager&#93; Using transaction object &#91;org.springframework.transaction.jta.JtaTransactionObject@72975c&#93;
                      12&#58;58&#58;03,446 DEBUG &#91;JtaTransactionManager&#93; Creating new transaction with name &#91;null&#93;
                      12&#58;58&#58;03,448 DEBUG &#91;JtaTransactionManager&#93; Beginning JTA transaction
                      12&#58;58&#58;03,459 DEBUG &#91;TransactionSynchronizationManager&#93; Initializing transaction synchronization
                      12&#58;58&#58;03,469 INFO  &#91;STDOUT&#93; *** doInTransaction [email protected]f2cbc0
                      12&#58;58&#58;03,471 INFO  &#91;STDOUT&#93; === Create TransactionTemplate 2
                      12&#58;58&#58;03,474 INFO  &#91;STDOUT&#93; === Propagation=3
                      12&#58;58&#58;03,478 DEBUG &#91;JtaTransactionManager&#93; Using transaction object &#91;org.springframework.transaction.jta.JtaTransactionObject@70ef09&#93;
                      12&#58;58&#58;03,480 DEBUG &#91;JtaTransactionManager&#93; Suspending current transaction, creating new transaction with name &#91;null&#93;
                      12&#58;58&#58;03,483 DEBUG &#91;JtaTransactionManager&#93; Suspending JTA transaction
                      12&#58;58&#58;03,485 DEBUG &#91;TransactionSynchronizationManager&#93; Clearing transaction synchronization
                      12&#58;58&#58;03,489 DEBUG &#91;JtaTransactionManager&#93; Beginning JTA transaction
                      12&#58;58&#58;03,491 DEBUG &#91;TransactionSynchronizationManager&#93; Initializing transaction synchronization
                      12&#58;58&#58;03,495 INFO  &#91;STDOUT&#93; === doInTransaction 2 [email protected]563eae
                      12&#58;58&#58;03,497 DEBUG &#91;JtaTransactionManager&#93; Triggering beforeCommit synchronization
                      12&#58;58&#58;03,498 DEBUG &#91;JtaTransactionManager&#93; Triggering beforeCompletion synchronization
                      12&#58;58&#58;03,500 DEBUG &#91;JtaTransactionManager&#93; Initiating transaction commit
                      12&#58;58&#58;03,501 DEBUG &#91;JtaTransactionManager&#93; Committing JTA transaction
                      12&#58;58&#58;03,504 DEBUG &#91;JtaTransactionManager&#93; Triggering afterCompletion synchronization
                      12&#58;58&#58;03,506 DEBUG &#91;TransactionSynchronizationManager&#93; Clearing transaction synchronization
                      12&#58;58&#58;03,566 DEBUG &#91;JtaTransactionManager&#93; Resuming suspended transaction
                      12&#58;58&#58;03,567 DEBUG &#91;TransactionSynchronizationManager&#93; Initializing transaction synchronization
                      12&#58;58&#58;03,567 DEBUG &#91;JtaTransactionManager&#93; Resuming JTA transaction
                      12&#58;58&#58;03,567 DEBUG &#91;JtaTransactionManager&#93; Triggering beforeCommit synchronization
                      12&#58;58&#58;03,567 DEBUG &#91;JtaTransactionManager&#93; Triggering beforeCompletion synchronization
                      12&#58;58&#58;03,567 DEBUG &#91;JtaTransactionManager&#93; Initiating transaction commit
                      12&#58;58&#58;03,567 DEBUG &#91;JtaTransactionManager&#93; Committing JTA transaction
                      12&#58;58&#58;03,568 DEBUG &#91;JtaTransactionManager&#93; Triggering afterCompletion synchronization
                      12&#58;58&#58;03,568 DEBUG &#91;TransactionSynchronizationManager&#93; Clearing transaction synchronization
                      12&#58;58&#58;03,570 INFO  &#91;STDOUT&#93; *** Done.

                      Comment


                      • #12
                        Hi,
                        Thanks Trisberg for your response, as i told in my previous post that issue is only coming when i am using Message Driven Bean in front of Spring transacted Pojo. I specified Bean Manage Transaction for my message driven bean. When i used UserTransaction + Transaction manager (from Jndi) by replacing code in Spring managed POJO it worked fine. And also when i remove Message driven bean and use the same old Spring Transacted POJo it also works fine. So the real problem comes with the introduction of Message Driven Bean. I will post my code in next post so that i could simplify it more. Onething i observed while writing test is that it only comes when you are actually using some transaction resource as well e.g. JDBC, simple code witout the involvement of any transaction resource did not cause any problem and i got the same log output as yours.I am really looking forward for the resolution of this issue and highly appreciate your concern. Did you see the JBoss issue? Kindly help me on urgent basis (a humble request only )

                        Comment


                        • #13
                          Hi,
                          I am posting my test code here. Remember i am using JBoss 4.0.1 sp1 and Oracle 10g as database.

                          My Message Driven Bean is as follows
                          TestingTransactionMDBBean.java
                          Code:
                          package jbosstransactiontest;
                          
                          import javax.ejb.*;
                          import javax.jms.*;
                          
                          
                          /**
                           * @ejb.bean name="TestingTransactionMDB"
                           *           display-name="TestingTransactionMDB"
                           *           description="Testing Bean"
                           *           destination-type="javax.jms.Queue"
                           *           acknowledge-mode="Auto-acknowledge"
                           *           transaction-type="Bean"
                           *
                           * @jboss.destination-jndi-name
                           *           name="queue/testQueue"
                           */
                          public class TestingTransactionMDBBean implements MessageDrivenBean,
                                  MessageListener
                          &#123;
                              MessageDrivenContext messageDrivenContext;
                              private ITestingTransactionService testingTransactionService;
                              public void ejbCreate&#40;&#41;
                              &#123;
                                  // this is how i get reference to Spring Transacted POJO. ApplicationContextSingleton
                                  // is a ApplicationContextAware Singleton defined in Spring Application Context.
                                  this.testingTransactionService = &#40;ITestingTransactionService&#41;
                                                                   ApplicationContextSingleton.
                                                                   getInstance&#40;&#41;.getBean&#40;
                                                                           "testingTransactionService"&#41;;
                              &#125;
                          
                              public void ejbRemove&#40;&#41;
                              &#123;
                              &#125;
                          
                              /**
                               * To facilitate testing i send text message in the Queue picked up by this Bean.
                               * @param message Message
                               */
                              public void onMessage&#40;Message message&#41;
                              &#123;
                                  try
                                  &#123;
                                      if &#40;message instanceof TextMessage&#41;
                                      &#123;
                                          TextMessage txMessage = &#40;TextMessage&#41; message;
                                          System.out.println&#40;txMessage.getText&#40;&#41;&#41;;
                                          
                                          // This is the call to Spring transacted POJO
                                          testingTransactionService.requiresTransaction&#40;&#41;;
                                      &#125;
                                  &#125;
                                  catch &#40;Exception ex&#41;
                                  &#123;
                                      ex.printStackTrace&#40;&#41;;
                                  &#125;
                              &#125;
                          
                              public void setMessageDrivenContext&#40;MessageDrivenContext
                                                                  messageDrivenContext&#41;
                              &#123;
                                  this.messageDrivenContext = messageDrivenContext;
                              &#125;
                          &#125;
                          Interface of My Spring Transacted POJO
                          Code:
                          package jbosstransactiontest;
                          
                          public interface ITestingTransactionService
                          &#123;
                              public String requiresTransaction&#40;&#41;;
                          &#125;
                          Spring Transacted POJO:
                          Code:
                          package jbosstransactiontest;
                          
                          import org.springframework.transaction.*;
                          import org.springframework.transaction.support.*;
                          
                          /**
                           * Spring Transacted POJO &#40;programmatic Transaction&#41;  
                           */
                          public class TestingTransactionService implements ITestingTransactionService
                          &#123;
                              private PlatformTransactionManager transactionManager;
                              private ITicketBufferDAO ticketBufferDAO;    
                          
                              public TestingTransactionService&#40;&#41;
                              &#123;
                              &#125;
                          
                              /**
                               * this method starts another transaction by having propagation level set to
                               * "Requires_new"
                               */
                              private void requiresNewTransaction&#40;&#41;
                              &#123;
                                  TransactionTemplate transactionTemplate = new TransactionTemplate&#40;this.
                                          transactionManager&#41;;
                                  transactionTemplate.setPropagationBehavior&#40;TransactionDefinition.
                                          PROPAGATION_REQUIRES_NEW&#41;;
                                  transactionTemplate.execute&#40;new TransactionCallbackWithoutResult&#40;&#41;
                                  &#123;
                                      public void doInTransactionWithoutResult&#40;TransactionStatus status&#41;
                                      &#123;
                                          System.out.println&#40;"requiresNewTransaction&#40;&#41; called"&#41;;
                                          ticketBufferDAO.test2&#40;&#41;;
                                      &#125;
                          
                                  &#125;&#41;;
                              &#125;
                          
                              /**
                               * This method start a Transaction with propagation level as "Required".
                               * @return String
                               */
                              public String requiresTransaction&#40;&#41;
                              &#123;
                                  TransactionTemplate transactionTemplate = new TransactionTemplate&#40;this.
                                          transactionManager&#41;;
                                  transactionTemplate.setPropagationBehavior&#40;TransactionDefinition.
                                          PROPAGATION_REQUIRED&#41;;
                                  transactionTemplate.execute&#40;new TransactionCallbackWithoutResult&#40;&#41;
                                  &#123;
                                      public void doInTransactionWithoutResult&#40;TransactionStatus status&#41;
                                      &#123;
                                          System.out.println&#40;"requiresTransaction&#40;&#41; called"&#41;;
                                          System.out.println&#40;ticketBufferDAO.test1&#40;&#41;&#41;;                
                                          
                                          // This is the call to a method which has propagation level set 
                                          // to "Requires_New" ---- Causing problem
                                          requiresNewTransaction&#40;&#41;;
                                          
                          
                                      &#125;
                                  &#125;&#41;;
                                  return "Hello";
                              &#125;
                          
                              public void setTransactionManager&#40;PlatformTransactionManager
                                                                transactionManager&#41;
                              &#123;
                                  this.transactionManager = transactionManager;
                              &#125;
                          
                              public void setTicketBufferDAO&#40;ITicketBufferDAO ticketBufferDAO&#41;
                              &#123;
                                  this.ticketBufferDAO = ticketBufferDAO;
                              &#125;
                          &#125;
                          My DAO interface ( i am using Oracle 0g)
                          Code:
                          package jbosstransactiontest;
                          
                          public interface ITicketBufferDAO
                          &#123;
                              public int test1&#40;&#41;;
                          
                              public void test2&#40;&#41;;
                          &#125;
                          The Simplified DAO
                          Code:
                          package jbosstransactiontest;
                          
                          import org.springframework.jdbc.core.support.*;
                          
                          
                          public class TicketBufferDAO extends JdbcDaoSupport implements ITicketBufferDAO
                          &#123;   
                              public TicketBufferDAO&#40;&#41;
                              &#123;
                          
                              &#125;  
                          
                              /**
                               * I have simplified it for testing only     
                               */
                              public int test1&#40;&#41;
                              &#123;
                                  return this.getJdbcTemplate&#40;&#41;.queryForInt&#40;"Select 1 from dual"&#41;;
                              &#125;
                              /**
                               * This is simplified too and use same query just for testing.
                               */
                              public void test2&#40;&#41;
                              &#123;
                                 this.getJdbcTemplate&#40;&#41;.queryForInt&#40;"Select 1 from dual"&#41;; 
                              &#125;
                          &#125;
                          My application context is as follows
                          Code:
                          <?xml version="1.0" encoding="UTF-8"?>
                          <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
                          
                          <!-- Application context definition for Common beans-->
                          <beans>
                            <!-- ========================= RESOURCE DEFINITIONS ========================= -->
                            <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
                              <property name="transactionManagerName"><value>java&#58;/TransactionManager</value></property>
                            </bean>
                            <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
                              <property name="jndiName"><value>java&#58;/XAOracleDS</value></property>
                            </bean>
                          
                            <bean id="ticketBufferDAO" class="jbosstransactiontest.TicketBufferDAO">
                              <property name="dataSource"><ref local="dataSource"/></property>
                            </bean>
                          
                             <bean id="testingTransactionService" class="jbosstransactiontest.TestingTransactionService">
                              <property name="transactionManager"><ref local="transactionManager"/></property>
                              <property name="ticketBufferDAO"><ref local="ticketBufferDAO"/></property>
                            </bean>
                          
                            <bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
                              <property name="jndiName"><value>jms/connectionFactory</value></property>
                              <property name="resourceRef"><value>true</value></property>
                            </bean>
                          
                            <bean id="receiveDestination" class="org.springframework.jndi.JndiObjectFactoryBean">
                              <property name="jndiName"><value>jms/testQueue</value></property>
                              <property name="resourceRef"><value>true</value></property>
                            </bean>
                            <bean id="jmsSender" class="jbosstransactiontest.JmsSender" init-method="initialize">
                              <property name="connectionFactory"><ref local="connectionFactory"/></property>
                              <property name="receiveDestination"><ref local="receiveDestination"/></property>
                            </bean>
                          
                            <bean id="applicationContextSingleton" class="jbosstransactiontest.ApplicationContextSingleton">  </bean>
                          </beans>
                          The core code is completed by above classes and you can use it.
                          I am using a servlet which in doGet() method places a Text message in the queue which is lisened by the above Message Driven Bean. Message could be any String it just needs to be TextMesage. Running the servlet initiates the whole test and after almost 5 second the exceptions came.

                          This code is not neccessary but i am posting it here.

                          This is the class used by MDB to lookup spring managed POJo for Spring App Context.
                          Code:
                          package jbosstransactiontest;
                          
                          import org.springframework.beans.*;
                          import org.springframework.context.*;
                          
                          public class ApplicationContextSingleton implements ApplicationContextAware
                          &#123;
                          
                              static ApplicationContext applicationContext;
                          
                              public static ApplicationContext getInstance&#40;&#41;
                              &#123;
                                  return applicationContext;
                              &#125;
                          
                              public ApplicationContextSingleton&#40;&#41;
                              &#123;
                              &#125;
                          
                              public void setApplicationContext&#40;ApplicationContext applicationContext&#41; throws
                                      BeansException
                              &#123;
                                  this.applicationContext = applicationContext;
                              &#125;
                          &#125;
                          The helper class to send message in JMS queue by the servlet
                          Code:
                          package jbosstransactiontest;
                          
                          import javax.jms.*;
                          
                          import org.apache.commons.logging.*;
                          import org.springframework.jms.core.*;
                          
                          public class JmsSender
                          &#123;
                              private final Log logger = LogFactory.getLog&#40;this.getClass&#40;&#41;&#41;;
                              private JmsTemplate jt;
                              private ConnectionFactory connectionFactory;
                              private Destination receiveDestination;
                          
                              public void initialize&#40;&#41;
                              &#123;
                                  jt = new JmsTemplate&#40;connectionFactory&#41;;
                              &#125;
                          
                              public void insertToTestDestination&#40;final String stringMessage&#41;
                              &#123;
                                  jt.send&#40;receiveDestination, new MessageCreator&#40;&#41;
                                  &#123;
                                      public Message createMessage&#40;Session session&#41; throws JMSException
                                      &#123;
                                          logger.info&#40;"inserting into receive queue"&#41;;
                                          return session.createTextMessage&#40;stringMessage&#41;;
                                      &#125;
                                  &#125;&#41;;
                              &#125;
                          
                              public void setConnectionFactory&#40;ConnectionFactory cf&#41;
                              &#123;
                                  connectionFactory = cf;
                              &#125;
                          
                              public void setReceiveDestination&#40;Destination receiveDestination&#41;
                              &#123;
                                  this.receiveDestination = receiveDestination;
                              &#125;
                          &#125;
                          The servlet which invokes the whole test by placing a Text message in the queue using JMSSender class
                          Code:
                          package jbosstransactiontest;
                          
                          import java.io.*;
                          
                          import javax.servlet.*;
                          import javax.servlet.http.*;
                          
                          import org.springframework.web.context.*;
                          import org.springframework.web.context.support.*;
                          
                          
                          public class TestingTransactionServlet extends HttpServlet
                          &#123;
                              private static final String CONTENT_TYPE = "text/html";
                              private JmsSender jmsSender;
                              public void init&#40;&#41; throws ServletException
                              &#123;
                                  WebApplicationContext webApplicationContext =
                                          WebApplicationContextUtils.getWebApplicationContext&#40;this.
                                          getServletContext&#40;&#41;&#41;;
                                  jmsSender = &#40;JmsSender&#41; webApplicationContext.getBean&#40;"jmsSender"&#41;;
                          
                              &#125;
                          
                          
                              //Process the HTTP Get request
                              public void doGet&#40;HttpServletRequest request, HttpServletResponse response&#41; throws
                                      ServletException, IOException
                              &#123;
                                  response.setContentType&#40;CONTENT_TYPE&#41;;
                                  PrintWriter out = response.getWriter&#40;&#41;;
                                  out.println&#40;"<html>"&#41;;
                                  out.println&#40;"<head><title>TestingTransactionServlet</title></head>"&#41;;
                                  out.println&#40;"<body bgcolor=\"#ffffff\">"&#41;;
                                  
                                  // Request to place message in JMS Queue
                                  jmsSender.insertToTestDestination&#40;"Hello Trisberg"&#41;;
                                  
                                  
                                  out.println&#40;"<p>The servlet has received a GET. This is the reply.</p>"&#41;;
                                  out.println&#40;"</body>"&#41;;
                                  out.println&#40;"</html>"&#41;;
                                  out.close&#40;&#41;;
                              &#125;
                          
                              //Clean up resources
                              public void destroy&#40;&#41;
                              &#123;
                              &#125;
                          &#125;
                          My web.xml looks like this
                          Code:
                          <?xml version="1.0" encoding="UTF-8"?>
                          <web-app xmlns="http&#58;//java.sun.com/xml/ns/j2ee" xmlns&#58;xsi="http&#58;//www.w3.org/2001/XMLSchema-instance" xsi&#58;schemaLocation="http&#58;//java.sun.com/xml/ns/j2ee http&#58;//java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
                            <display-name>TestingTransactionWebModule</display-name>
                            <context-param>
                              <param-name>contextConfigLocation</param-name>
                              <param-value>/WEB-INF/applicationContext.xml</param-value>
                            </context-param>
                            <listener>
                              <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
                            </listener>
                            <servlet>
                              <servlet-name>testingtransactionservlet</servlet-name>
                              <servlet-class>jbosstransactiontest.TestingTransactionServlet</servlet-class>
                            </servlet>
                            <servlet-mapping>
                              <servlet-name>testingtransactionservlet</servlet-name>
                              <url-pattern>/testingtransactionservlet</url-pattern>
                            </servlet-mapping>
                            <resource-env-ref>
                              <resource-env-ref-name>jms/testQueue</resource-env-ref-name>
                              <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
                            </resource-env-ref>
                            <resource-ref>
                              <description>JMS Connection Factory</description>
                              <res-ref-name>jms/connectionFactory</res-ref-name>
                              <res-type>javax.jms.QueueConnectionFactory</res-type>
                              <res-auth>Container</res-auth>
                              <res-sharing-scope>Shareable</res-sharing-scope>
                            </resource-ref>
                          </web-app>
                          And finally my jboss-web.xml is
                          Code:
                          <?xml version="1.0" encoding="UTF-8"?>
                          <!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.4//EN" "http&#58;//www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
                          
                          <jboss-web>
                            <context-root>TestingTransactionWebModule</context-root>
                            <resource-env-ref>
                              <resource-env-ref-name>jms/testQueue</resource-env-ref-name>
                              <jndi-name>queue/testQueue</jndi-name>
                            </resource-env-ref>
                            <resource-ref>
                              <res-ref-name>jms/connectionFactory</res-ref-name>
                              <jndi-name>java&#58;/JmsXA</jndi-name>
                            </resource-ref>
                          </jboss-web>
                          I know it looks like a lot of code but it is very simple one just a test. So trisberg now i feel that you could really help me. Please make it clear that problem starts when we have MDB + Spring Programmaticllay Transacted POJO + Actual Transactional Resource usage. I am highly obliged by the help you are proving so far and looking forward for the resoultion.

                          Comment


                          • #14
                            Hi,
                            Still waiting for your reply. Please help me asap.

                            Comment


                            • #15
                              I have been able to reproduce this locally.

                              I have created a new JIRA entry for this issue - http://opensource2.atlassian.com/pro...rowse/SPR-1384

                              Comment

                              Working...
                              X