4 Replies Latest reply on May 3, 2007 4:54 PM by Pete Muir

    Mysterious "Transaction is not active" when trying to get Co

    Zeev Lazarev Newbie

      Hi,

      I'm using jboss-4.0.4 and MySQL.
      When I try to get a Connection from java.sql.DataSource obj I get the follwing exception:

      Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=ZEEV/16, BranchQual=, localId
      =16])
      23:48:10,921 INFO [CachedConnectionManager] Closing a connection for you. Please close them yourself: org.jboss.resource.adapter.jdbc.WrappedConnection@15
      23de0
      java.lang.Throwable: STACKTRACE
      at org.jboss.resource.connectionmanager.CachedConnectionManager.registerConnection(CachedConnectionManager.java:290)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:400)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:812)
      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:88)
      at com.compushop.storage.CompushopDatasourceFactory.getCompushopDatasource(CompushopDatasourceFactory.java:55)
      at com.compushop.ejb.session.StorageSessionBeanHelper.initCompushopDatasource(StorageSessionBeanHelper.java:47)
      at com.compushop.ejb.session.StorageSessionBeanHelper.getStoreProvider(StorageSessionBeanHelper.java:59)
      at com.compushop.ejb.session.SessionDSBean.searchCategories(SessionDSBean.java:107)
      at com.compushop.ejb.session.SessionDSBean.getCategoryData(SessionDSBean.java:88)
      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:585)
      at org.jboss.invocation.Invocation.performCall(Invocation.java:359)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:237)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:158)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:169)
      at org.jboss.ws.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:64)
      at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)


      Googling this exception I found that increasing a time out for the TransactionManagerService in jboss-service.xml solves the issue.
      So I changed TransactionTimeout attribe from 300 to 3000.
      This partly solved my problem. The first datasrc.getConnection()
      I pass smoothly. When I try to allocate another connection from a datasource I fail on the same exception "Transaction is not active".
      I obtain a datasource object through jndi:

      String jndiName = "mydb";
      InitialContext ctx = new InitialContext();
      datasrc = (DataSource) ctx.lookup("java:" + jndiName);
      Connection conn = datasrc.getConnection();

      Thanks.
      Zeev

        • 1. Re: Mysterious
          Gavin King Master

          No! That is not the solution! Instead makse sure you call close() on all connections, as is required by the JCA spec.

          • 2. Re: Mysterious
            Sunil Newbie

            Gavin,
            i have all my database connections closed. I tried increasing the transaction timeout parameter in jboss-service.xml.
            Even then i have the same problem.

            Actually am getting this error when am trying catch and insert an exception into the database (oracle/derby).

            Any suggestions/workarounds regarding this transaction problem will be higjly appreciated.

            Error:

            13:41:54,281 ERROR [STDERR] org.jboss.util.NestedSQLException: Transaction is not active: tx=TransactionImpl:XidImpl[For
            matId=257, GlobalId=dcg00187/598, BranchQual=, localId=598]; - nested throwable: (javax.resource.ResourceException: Tran
            saction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=dcg00187/598, BranchQual=, localId=598])
            13:41:54,296 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.jav
            a:94)
            13:41:54,312 ERROR [STDERR] at ejb.mdc.dao.MdcDataImpl.getConnection(MdcDataImpl.java:138)
            13:41:54,312 ERROR [STDERR] at ejb.mdc.dao.MdcDataImpl.insertData(MdcDataImpl.java:42)
            13:41:54,312 ERROR [STDERR] at ejb.mdc.write.MDCWriteCatalogBean.insertData(MDCWriteCatalogBean.java:787)
            13:41:54,312 ERROR [STDERR] at ejb.mdc.write.MDCWriteCatalogBean.addOrUpdateMetaData(MDCWriteCatalogBean.java:514)
            13:41:54,328 ERROR [STDERR] at ejb.mdc.write.MDCWriteCatalogBean.writeMDCMessage(MDCWriteCatalogBean.java:278)
            13:41:54,328 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            13:41:54,328 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            13:41:54,343 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

            13:41:54,343 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
            13:41:54,359 ERROR [STDERR] at org.jboss.invocation.Invocation.performCall(Invocation.java:359)
            13:41:54,359 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionC
            ontainer.java:237)
            13:41:54,359 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnect
            ionInterceptor.java:158)
            13:41:54,375 ERROR [STDERR] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInst
            anceInterceptor.java:169)
            13:41:54,390 ERROR [STDERR] at org.jboss.ws.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java
            :39)
            13:41:54,390 ERROR [STDERR] at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java
            :63)
            13:41:54,406 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121
            )
            13:41:54,406 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)

            13:41:54,421 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
            13:41:54,421 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:168)
            13:41:54,437 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
            13:41:54,437 ERROR [STDERR] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderIntercep
            tor.java:136)
            13:41:54,453 ERROR [STDERR] at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:648)
            13:41:54,453 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:954)
            13:41:54,453 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            13:41:54,453 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            13:41:54,468 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

            13:41:54,468 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
            13:41:54,468 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
            13:41:54,484 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
            13:41:54,484 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
            13:41:54,484 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
            13:41:54,500 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
            13:41:54,500 ERROR [STDERR] at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.jav
            a:819)
            13:41:54,515 ERROR [STDERR] at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:420)
            13:41:54,515 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            13:41:54,515 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            13:41:54,531 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

            13:41:54,531 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
            13:41:54,531 ERROR [STDERR] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
            13:41:54,546 ERROR [STDERR] at sun.rmi.transport.Transport$1.run(Transport.java:153)
            13:41:54,546 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
            13:41:54,546 ERROR [STDERR] at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
            13:41:54,562 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
            13:41:54,562 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
            13:41:54,562 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
            13:41:54,578 ERROR [STDERR] Caused by: javax.resource.ResourceException: Transaction is not active: tx=TransactionImpl:X
            idImpl[FormatId=257, GlobalId=dcg00187/598, BranchQual=, localId=598]
            13:41:54,671 ERROR [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConne
            ctionManager.java:290)
            13:41:54,671 ERROR [STDERR] at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseCo
            nnectionManager2.java:379)
            13:41:54,671 ERROR [STDERR] at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.al
            locateConnection(BaseConnectionManager2.java:812)
            13:41:54,671 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.jav
            a:88)
            13:41:54,671 ERROR [STDERR] ... 45 more
            13:41:54,671 ERROR [STDERR] java.lang.NullPointerException
            13:41:54,671 ERROR [STDERR] at ejb.mdc.dao.MdcDataImpl.insertData(MdcDataImpl.java:71)
            13:41:54,671 ERROR [STDERR] at ejb.mdc.write.MDCWriteCatalogBean.insertData(MDCWriteCatalogBean.java:787)
            13:41:54,671 ERROR [STDERR] at ejb.mdc.write.MDCWriteCatalogBean.addOrUpdateMetaData(MDCWriteCatalogBean.java:514)
            13:41:54,671 ERROR [STDERR] at ejb.mdc.write.MDCWriteCatalogBean.writeMDCMessage(MDCWriteCatalogBean.java:278)
            13:41:54,671 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            13:41:54,671 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            13:41:54,671 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

            13:41:54,671 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
            13:41:54,671 ERROR [STDERR] at org.jboss.invocation.Invocation.performCall(Invocation.java:359)
            13:41:54,671 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionC
            ontainer.java:237)
            13:41:54,671 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnect
            ionInterceptor.java:158)
            13:41:54,671 ERROR [STDERR] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInst
            anceInterceptor.java:169)
            13:41:54,671 ERROR [STDERR] at org.jboss.ws.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java
            :39)
            13:41:54,671 ERROR [STDERR] at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java
            :63)
            13:41:54,671 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121
            )
            13:41:54,671 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)

            13:41:54,671 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
            13:41:54,671 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:168)
            13:41:54,671 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
            13:41:54,671 ERROR [STDERR] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderIntercep
            tor.java:136)
            13:41:54,671 ERROR [STDERR] at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:648)
            13:41:54,671 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:954)
            13:41:54,671 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            13:41:54,671 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            13:41:54,671 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

            13:41:54,671 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
            13:41:54,671 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
            13:41:54,671 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
            13:41:54,671 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
            13:41:54,671 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
            13:41:54,671 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
            13:41:54,671 ERROR [STDERR] at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.jav
            a:819)
            13:41:54,671 ERROR [STDERR] at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:420)
            13:41:54,671 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            13:41:54,671 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            13:41:54,671 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

            13:41:54,671 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
            13:41:54,671 ERROR [STDERR] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
            13:41:54,671 ERROR [STDERR] at sun.rmi.transport.Transport$1.run(Transport.java:153)
            13:41:54,671 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
            13:41:54,671 ERROR [STDERR] at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
            13:41:54,671 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
            13:41:54,671 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
            13:41:54,671 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)


            Thanks you
            Sunil

            • 3. Re: Mysterious
              Toni Beckman Novice

              The timeout is set in another .xml file. Maybe this helps you:

              http://www.jboss.com/index.html?module=bb&op=viewtopic&t=101719

              • 4. Re: Mysterious
                Pete Muir Master

                Please start a new thread and explain your problem in full, and state your environment and code.