9 Replies Latest reply on Jan 16, 2009 7:36 AM by Mark Little

    Transaction is not active

    Vinay Kumar Newbie

      I'm getting following exception when running multiple clients accessing my SLSB on JBoss 4.2.2.GA / Remoting 2.4.0.SP1 / PostgreSQL 8.3.

      Please suggest the required changes.

      <log4j:event logger="org.hibernate.util.JDBCExceptionReporter" timestamp="1230028593145" level="WARN" thread="WorkerThread#60[150.158.72.149:2547]">
      <log4j:message><![CDATA[SQL Error: 0, SQLState: null]]></log4j:message>
      </log4j:event>

      <log4j:event logger="org.hibernate.util.JDBCExceptionReporter" timestamp="1230028593145" level="ERROR" thread="WorkerThread#60[150.158.72.149:2547]">
      <log4j:message><![CDATA[Transaction is not active: tx=TransactionImple < ac, BasicAction: -6961b782:a8b:4950ae26:a388d status: ActionStatus.ABORT_ONLY >; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: -6961b782:a8b:4950ae26:a388d status: ActionStatus.ABORT_ONLY >)]]></log4j:message>
      </log4j:event>

      <log4j:event logger="com.barco.cms.logging.LogServer" timestamp="1230028593583" level="DEBUG" thread="Thread-12">
      <log4j:message><![CDATA[Connection received from /150.158.72.149]]></log4j:message>
      </log4j:event>

      <log4j:event logger="com.barco.cms.service.sourcemgt.SourcePoolImpl" timestamp="1230028593286" level="WARN" thread="WorkerThread#87[150.158.74.117:2607]">
      <log4j:message><![CDATA[Exception occured while retriving ScreenScrapeSources returns empty list ]]></log4j:message>
      <log4j:throwable><![CDATA[javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Cannot open connection
      at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:629)
      at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:73)
      at com.barco.cms.service.sourcemgt.SourcePoolImpl.getScreenScrapeSources(Unknown Source)
      at com.barco.cms.service.perspectivemgt.Display.createProSource(Unknown Source)
      at com.barco.cms.service.perspectivemgt.Display.setOnline(Unknown Source)
      at com.barco.cms.openapi.PerspectiveMgtAPIImpl.setDisplayInfo(Unknown Source)
      at sun.reflect.GeneratedMethodAccessor224.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
      at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
      at com.barco.cms.openapi.PerspectiveMgtAPIImpl.initialSteps(Unknown Source)
      at sun.reflect.GeneratedMethodAccessor102.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:146)
      at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
      at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
      at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:304)
      at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
      at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
      at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:908)
      at org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:742)
      at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:695)
      at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:549)
      at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:230)
      Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection
      at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
      at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
      at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
      at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
      at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:426)
      at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
      at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
      at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
      at org.hibernate.loader.Loader.doQuery(Loader.java:673)
      at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
      at org.hibernate.loader.Loader.doList(Loader.java:2220)
      at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
      at org.hibernate.loader.Loader.list(Loader.java:2099)
      at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
      at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
      at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
      at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
      at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
      at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:64)
      ... 42 more
      Caused by: org.jboss.util.NestedSQLException: Transaction is not active: tx=TransactionImple < ac, BasicAction: -6961b782:a8b:4950ae26:a35f4 status: ActionStatus.ABORT_ONLY >; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: -6961b782:a8b:4950ae26:a35f4 status: ActionStatus.ABORT_ONLY >)
      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:94)
      at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:47)
      at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
      ... 56 more
      Caused by: javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: -6961b782:a8b:4950ae26:a35f4 status: ActionStatus.ABORT_ONLY >
      at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:304)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:396)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:842)
      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:88)
      ... 58 more
      ]]></log4j:throwable>
      </log4j:event>

        • 1. Re: Transaction is not active
          Mark Little Master

          Something has marked your transaction as rollback-only. Without more information on what you're trying to do or Santa bringing me that Psychic Helmet I've always dreamed of, I can't say more. I'm on vacation for the next couple of weeks, so that may give you time to more carefully construct your subsequent request for help.

          • 2. Re: Transaction is not active
            Vinay Kumar Newbie

            Hello Mark,

            Thanks for your reply.

            This exception sporadically appears from any call placed on my SLSB. But, the noticeable point is that it only appears when multiple clients are connected with server & are working actively.

            Another thing to note that, if you look at the stack;
            at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:73)
            at com.barco.cms.service.sourcemgt.SourcePoolImpl.getScreenScrapeSources(Unknown Source)
            at com.barco.cms.service.perspectivemgt.Display.createProSource(Unknown Source)
            at com.barco.cms.service.perspectivemgt.Display.setOnline(Unknown Source)
            at com.barco.cms.openapi.PerspectiveMgtAPIImpl.setDisplayInfo(Unknown Source)

            My first call is setDisplayInfo which is a method declared in SLSB. It looks up an entity Display & tries to set Online property. Inside that entity it tries to create a new entity PROSource. To create this source, it uses a POJO which tries to lookup all ScreenScrapeSources using the injected EntityManager of SLSB. And, then this problem appears. No other clues.

            • 3. Re: Transaction is not active
              Mark Little Master

              Turn on debugging and check to see what it is that is calling setRollbackOnly on your transaction.

              • 4. Re: Transaction is not active
                Saurav Kumar Newbie

                Hello All,

                In reference to the same problem reported by VINK.

                Any idea, how to put an interceptor that tells which api is setting transaction to rollback? As we have various pojo pools as well which is making use of entitymanager passed through constructor.

                Regards,
                Saurav

                • 5. Re: Transaction is not active
                  Saurav Kumar Newbie

                  Hello Mark,
                  Just little remark, if any transaction is marked for rollback then we are getting the correct exception telling about transaction is roll backed. In some cases where we are catching persistence exception and proceeding further in same transaction then it is saying Entity must be accessed within transaction.

                  But in no case any sample program able to give above mentioned exception. Probably there is some other reason for it.

                  Any one else can comment about it.

                  Regards,
                  Saurav

                  • 6. Re: Transaction is not active
                    Mark Little Master

                    Not sure what you mean, but "must be accessed within a transaction" could mean that there is no transaction associated with the thread of control. That's different from the transaction not being active.

                    • 7. Re: Transaction is not active
                      Saurav Kumar Newbie

                      I mean I have situation where I putting em.flush under try catch and proceeding further for doing more operation on em. but flush got failed because of some unknown reason. {same piece of code work most of the time only some time in concurrent env it is giving exceptions}

                      Then the excpetion is comming as shown below not 'Tx Not Active'

                      <log4j:throwable><![CDATA[javax.persistence.TransactionRequiredException: EntityManager must be access within a transaction
                      at org.jboss.ejb3.entity.ManagedEntityManagerFactory.verifyInTx(ManagedEntityManagerFactory.java:150)
                      at org.jboss.ejb3.entity.TransactionScopedEntityManager.flush(TransactionScopedEntityManager.java:210)
                      at com.barco.cms.service.perspectivemgt.DisplayEventSupport.fireDisplayWindowSharedEvent(Unknown Source)
                      at com.barco.cms.service.perspectivemgt.Display.shareWindow(Unknown Source)
                      at com.barco.cms.service.perspectivemgt.Display.findPerspectiveAndActivateShared(Unknown Source)
                      at com.barco.cms.service.perspectivemgt.Display.openAndSharePerspective(Unknown Source)
                      at com.barco.cms.service.perspectivemgt.Display.openPerspective(Unknown Source)
                      at com.barco.cms.service.perspectivemgt.Display.openPerspective(Unknown Source)
                      at com.barco.cms.openapi.PerspectiveMgtAPIImpl.openPerspectiveWithDefaultGeometry(Unknown Source)
                      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:597)
                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
                      at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
                      at com.barco.cms.openapi.PerspectiveMgtAPIImpl.initialSteps(Unknown Source)
                      at sun.reflect.GeneratedMethodAccessor103.invoke(Unknown Source)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                      at java.lang.reflect.Method.invoke(Method.java:597)
                      at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:146)
                      at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                      at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                      at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                      at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
                      at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                      at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                      at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                      at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
                      at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                      at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                      at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                      at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:304)
                      at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
                      at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
                      at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:908)
                      at org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:742)
                      at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:695)
                      at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:549)
                      at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:230)
                      ]]></log4j:throwable>
                      </log4j:event>

                      • 8. Re: Transaction is not active
                        Saurav Kumar Newbie

                        I mean I have situation where I am putting em.flush under try catch and proceeding further for doing more operation on em. but flush got failed because of some unknown reason. {same piece of code work most of the time only some time in concurrent env it is giving exceptions}

                        Then the excpetion is comming as shown below not 'Tx Not Active'

                        <log4j:throwable><![CDATA[javax.persistence.TransactionRequiredException: EntityManager must be access within a transaction
                        at org.jboss.ejb3.entity.ManagedEntityManagerFactory.verifyInTx(ManagedEntityManagerFactory.java:150)
                        at org.jboss.ejb3.entity.TransactionScopedEntityManager.flush(TransactionScopedEntityManager.java:210)
                        at com.barco.cms.service.perspectivemgt.DisplayEventSupport.fireDisplayWindowSharedEvent(Unknown Source)
                        at com.barco.cms.service.perspectivemgt.Display.shareWindow(Unknown Source)
                        at com.barco.cms.service.perspectivemgt.Display.findPerspectiveAndActivateShared(Unknown Source)
                        at com.barco.cms.service.perspectivemgt.Display.openAndSharePerspective(Unknown Source)
                        at com.barco.cms.service.perspectivemgt.Display.openPerspective(Unknown Source)
                        at com.barco.cms.service.perspectivemgt.Display.openPerspective(Unknown Source)
                        at com.barco.cms.openapi.PerspectiveMgtAPIImpl.openPerspectiveWithDefaultGeometry(Unknown Source)
                        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:597)
                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
                        at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
                        at com.barco.cms.openapi.PerspectiveMgtAPIImpl.initialSteps(Unknown Source)
                        at sun.reflect.GeneratedMethodAccessor103.invoke(Unknown Source)
                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                        at java.lang.reflect.Method.invoke(Method.java:597)
                        at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:146)
                        at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                        at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                        at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                        at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
                        at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                        at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                        at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                        at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
                        at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                        at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                        at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                        at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:304)
                        at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
                        at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
                        at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:908)
                        at org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:742)
                        at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:695)
                        at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:549)
                        at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:230)
                        ]]></log4j:throwable>
                        </log4j:event>

                        • 9. Re: Transaction is not active
                          Mark Little Master

                          Then you need to figure out why your thread isn't associated with a transaction. All I can suggest it attaching a debugger and walking through the application.