12 Replies Latest reply on Apr 29, 2011 5:59 AM by wdfink

    Transaction is not active

    mlefevre

      Hi,

      When I have a long process (a few minutes) and then perform a database operation. I have the following exception:
      ERROR 21 Mar 2006 15:50:54,910 util.EJBHomeFactory - org.jboss.util.NestedSQLException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=dimitrawcmtest.agri.cec.eu.int/309, BranchQual=, localId=309]; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=dimitrawcmtest.agri.cec.eu.int/309, BranchQual=, localId=309])
      org.jboss.util.NestedSQLException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=dimitrawcmtest.agri.cec.eu.int/309, BranchQual=, localId=309]; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=dimitrawcmtest.agri.cec.eu.int/309, BranchQual=, localId=309]) at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:79) at

      Any idea of what I should look at?

      Thanks

      Marc Lefèvre

        • 1. Re: Transaction is not active

          Hi ,
          This occurs because the Jboss Transaction Manger time out the underlying connection if your database transactions are longer. One way to prevent is,
          first find the piece of code i <mbean code="org.jboss.tm.TransactionManagerService"
          name="jboss:service=TransactionManager"
          xmbean-dd="resource:xmdesc/TransactionManagerService-xmbean.xml">
          300
          <!-- set to false to disable transaction demarcation over IIOP -->
          true
          <depends optional-attribute-name="XidFactory">jboss:service=XidFactory

          in the file jboss-service.xml and change the

          < attribute name="TransactionTimeout" >300< /attribute >

          to some larger value so that your transaction does not time out.
          Hope this helps.

          Regards
          Sriram

          • 2. Re: Transaction is not active
            mlefevre

            Hi, Thank a lot. I have changed the configuration and now it is working fine.

            Best Regards

            Marc

            • 3. Re: Transaction is not active
              gorakshnath

              i am getting same type of exceptions ,
              could u please tell me the number u changed so that ur application works fine ?

              also what is max value i can give ?

              what is effect if i set that value to max ?

              • 4. Re: Transaction is not active
                holeinone

                Well, this value is basically to protect you from never ending operations. (deadlocks)
                So fill in a value (in seconds) after which your longest transaction cannot possibly return a valid value.
                For instance: say your longest transaction takes at most 10 minutes to complete. Then, after say 15 minutes, you can be reasonably sure the transaction failed. You fill in 15*60=900 seconds.

                Hugo
                p.s. this will also mean that a transaction normally taking millisecond to complete will also only timeout after 15 minutes .... A lot can go wrong in 15 minutes.
                As a rule of the thub: always make your transactions as short as possible! Please check to see if you can re-design your application such that you do not need to adjust this value.

                • 5. Re: Transaction is not active
                  itechmani

                  Hi, am facing the very same exception, i tried changing the parameter you specifed as well. But am using JBOSS 4.2, so the jboss-service.xml said the block of code you specified is inactive and asked me to use the below lines of code instead.

                  <mbean code="com.arjuna.ats.jbossatx.jta.TransactionManagerService"
                   name="jboss:service=TransactionManager">
                   <attribute name="TransactionTimeout">3000000</attribute>
                   <attribute name="ObjectStoreDir">${jboss.server.data.dir}/tx-object-store</attribute>
                   </mbean>
                  


                  Also i canged the transaction timed out from 300 to a very huge value. Still the issue persist. Can you kindly advice me to get this issue resolved.

                  • 6. Re: Transaction is not active
                    itechmani

                    I have made the connection time to an hour from the very huge time given above. Please find the below change that i made to jboss-service.config file in the conf folder under messaging profile where i deploy my application.

                    <mbean code="com.arjuna.ats.jbossatx.jta.TransactionManagerService"
                     name="jboss:service=TransactionManager">
                     <attribute name="TransactionTimeout">3600</attribute>
                     <attribute name="ObjectStoreDir">${jboss.server.data.dir}/tx-object-store</attribute>
                     </mbean>
                    


                    • 7. Re: Transaction is not active
                      itechmani

                       

                      "itechmani" wrote:
                      I have made the connection time to an hour from the very huge time given above. Please find the below change that i made to jboss-service.config file in the conf folder under messaging profile where i deploy my application.

                      <mbean code="com.arjuna.ats.jbossatx.jta.TransactionManagerService"
                       name="jboss:service=TransactionManager">
                       <attribute name="TransactionTimeout">3600</attribute>
                       <attribute name="ObjectStoreDir">${jboss.server.data.dir}/tx-object-store</attribute>
                       </mbean>
                      

                      Still am facing the issue. Kindly help me to get this resolved.


                      • 8. Re: Transaction is not active
                        holeinone

                        You got a real, genuine, deadlock there.
                        2 threads fighting over the same resources.
                        When you set the timeout to an hour instead of 5 minutes it means only that the threads where fighting for the whole hour instead of 5 minutes.
                        There is no easy answer for this I'm afraid.
                        The application must be re-designed to prevent two threads wanting the same resource (database rows) at the same time.

                        H

                        • 9. Re: Transaction is not active
                          jayakar914

                          Solution is :

                           

                          Open File transaction-jboss-beans.xml in jboss-5.1.0.GA\server\all\deploy ,in that

                           

                          <bean name="TransactionManager" class="com.arjuna.ats.jbossatx.jta.TransactionManagerService">
                                  <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss:service=TransactionManager", exposedInterface=com.arjuna.ats.jbossatx.jta.TransactionManagerServiceMBean.class, registerDirectly=true)</annotation>
                                  <annotation>@org.jboss.managed.api.annotation.ManagementObject(name="TransactionManager",componentType=@org.jboss.managed.api.annotation.ManagementComponent(type = "MCBean", subtype = "JTA"),targetInterface=com.arjuna.ats.jbossatx.jta.TransactionManagerServiceMBean.class)</annotation>

                                  <property name="transactionTimeout">300</property>
                                  <property name="objectStoreDir">${jboss.server.data.dir}/tx-object-store</property>
                                  <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>

                           

                          give maximum value for transactionTimeout like 43200 , it will prevent that Exception.

                           

                          <property name="transactionTimeout">43200</property>

                           

                          This is the finest solution for Jboss Server

                          • 10. Transaction is not active
                            wdfink

                            Hi Jayakar,

                            you should look at the last post date you are updating a 5 year old thread where the last post is 2 years old.

                            • 11. Re: Transaction is not active
                              theju

                              how can i include transaction in java api?

                               

                              Thanks,

                               

                              http://mavilayi.com

                              • 12. Transaction is not active
                                wdfink

                                Hi Thej Thej,

                                you should start a new thread instad of posting to an old one which not match your question.

                                 

                                Please describe what you mean 'include Tx in java api' is not a specific question.