0 Replies Latest reply on Dec 28, 2006 11:00 AM by Konstantin Sobolev

    "Transaction is not active" after rollback

    Konstantin Sobolev Newbie

      Hi,

      Our EJB app contains a servlet which runs a number of daemon threads on startup. Threads access entity beans that use common JDBC connections pool.
      I'm observing strange problems in the following scenario:
      - daemon calls entity bean finder
      - (due to our bug) finder generates NPE and fails
      As far as I can see it all happens without a TX context, so there's nothing to rollback.
      - another daemon thread tries to get a connection from the pool but hits "Transaction is not active".

      It looks like some connection in the pool gets 'broken', daemon threads can't ever get DB connections after this.

      Here's a relevant stack trace:


      2006-12-27 14:43:29,158 ERROR [jb.plugins.LogInterceptor] TransactionRolledbackException in method: public abstract java.util.Collection com.supportwizard.dml.interfaces.SWRecordHome.findByTableAndFieldValue(com.supportwizard.seance.Seance,java.lang.Long,java.lang.String,java.lang.Object) throws javax.ejb.FinderException,java.rmi.RemoteException, causedBy:
      java.lang.NullPointerException
      at java.lang.StringBuffer.<init>(StringBuffer.java:104)
      at com.supportwizard.db.SQLBase.prepareColumnName(SQLBase.java:179)
      at com.supportwizard.db.SQLBase.prepareWhere(SQLBase.java:100)
      at com.supportwizard.db.SQLText_mysql.getQueryText(SQLText_mysql.java:133)
      at com.supportwizard.db.SQLText.getQueryText(SQLText.java:121)
      at com.supportwizard.db.SWInternal_SQL.sqlQuery(SWInternal_SQL.java:470)
      at com.supportwizard.db.SWInternal_SQL.sqlQuery(SWInternal_SQL.java:447)
      at com.supportwizard.utils.ejb.SWBMPEntityBean.genericMultiFind(SWBMPEntityBean.java:957)
      at com.supportwizard.utils.ejb.SWBMPEntityBean.genericMultiFind(SWBMPEntityBean.java:920)
      at com.supportwizard.utils.ejb.SWBMPEntityBean.genericMultiFind(SWBMPEntityBean.java:865)
      at com.supportwizard.utils.ejb.SWBMPEntityBean.genericMultiFind(SWBMPEntityBean.java:834)
      at com.supportwizard.dml.ejb.SWRecordBean.ejbFindByTableAndFieldValues(SWRecordBean.java:447)
      at com.supportwizard.dml.ejb.SWRecordBean.ejbFindByTableAndFieldValue(SWRecordBean.java:401)
      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.ejb.plugins.BMPPersistenceManager.callFinderMethod(BMPPersistenceManager.java:632)
      at org.jboss.ejb.plugins.BMPPersistenceManager.findEntities(BMPPersistenceManager.java:335)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.findEntities(CachedConnectionInterceptor.java:242)
      at org.jboss.ejb.EntityContainer.find(EntityContainer.java:706)
      at sun.reflect.GeneratedMethodAccessor179.invoke(Unknown Source)
      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.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1130)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:203)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:189)
      at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:105)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:134)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:76)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:43)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:125)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:378)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:161)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:145)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:132)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:107)
      at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:514)
      at org.jboss.ejb.Container.invoke(Container.java:975)
      at sun.reflect.GeneratedMethodAccessor174.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:169)
      at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:118)
      at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:206)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:192)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:61)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:70)
      at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:184)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)
      at $Proxy1164.findByTableAndFieldValue(Unknown Source)
      at com.supportwizard.swmail.daemon.UserHelper.getUserIdByEmailColumns(UserHelper.java:208)
      at com.supportwizard.swmail.daemon.UserHelper.getUserIdByEmailAndProject(UserHelper.java:181)
      at com.supportwizard.swmail.daemon.EmailDaemon.processIncomingMail(EmailDaemon.java:243)
      at com.supportwizard.swmail.daemon.EmailDaemon.run(EmailDaemon.java:784)
      at com.supportwizard.swmail.daemon.manager.TaskCarrier.run(TaskCarrier.java:84)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
      at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:280)
      at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:135)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:65)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:142)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:166)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
      at java.lang.Thread.run(Thread.java:595)
      2006-12-27 14:43:29,163 ERROR [.InboundEmailFilterHelper] Delete not accepted
      2006-12-27 14:43:29,168 WARN [swmail.daemon.EmailDaemon] Checking email failed
      com.supportwizard.utils.SWRuntimeException: com.supportwizard.db.SW_SQLException: Exception in DBConnect
      at com.supportwizard.swmail.MailStorageBase.dbConnect(MailStorageBase.java:40)
      at com.supportwizard.swmail.ReceivedMailsStorage.delete(ReceivedMailsStorage.java:221)
      at com.supportwizard.swmail.daemon.EmailDaemon.run(EmailDaemon.java:785)
      at com.supportwizard.swmail.daemon.manager.TaskCarrier.run(TaskCarrier.java:84)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
      at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:280)
      at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:135)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:65)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:142)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:166)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
      at java.lang.Thread.run(Thread.java:595)
      Caused by: com.supportwizard.db.SW_SQLException: Exception in DBConnect
      at com.supportwizard.db.SWInternal_SQL.dbConnect(SWInternal_SQL.java:263)
      at com.supportwizard.db.SWInternal_SQL.dbConnect(SWInternal_SQL.java:213)
      at com.supportwizard.swmail.MailStorageBase.dbConnect(MailStorageBase.java:37)
      ... 12 more
      Caused by: org.jboss.util.NestedSQLException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=server7/3995, BranchQual=, localId=3995]; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=server7/3995, BranchQual=, localId=3995])
      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:94)
      at com.supportwizard.db.SWInternal_SQL.dbConnect(SWInternal_SQL.java:253)
      ... 14 more
      Caused by: javax.resource.ResourceException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=server7/3995, BranchQual=, localId=3995]
      at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:290)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:379)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:812)
      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:88)
      ... 15 more


      The first 'TransactionRolledBack' message makes me think that in fact there is a transaction, but I can't find where it is created. UserTransaction isn't used anywhere, SWRecordBean finders are marked as 'Supports'.

      Of course we will fix this NPE, but the fact that such exception can leave connection pool in an inconsistent state really frightens me.
      Is it a JBoss bug or we're doing something wrong?

      Thanks.