6 Replies Latest reply on May 9, 2006 9:50 PM by Gavin King

    Problem while using @Rollback annotation

    Mathias Rügner Newbie

      I have deployed a webapp using Seam 1.0 RC1, jBPM and Hibernate
      on Tomcat using Microcontainer and SeamExtendedManagedPersistencePhaseListener.

      When I trigger a JSF action method of a conversation-scoped
      seam-managed JavaBean wich is annotated with
      @Rollback (see code below) everything is ok as long as
      the outcome is not null and no rollback is performed.

      @Name("erstattungAnlegenCtrl")
      @Scope(CONVERSATION)
      public class ErstattungAnlegenController extends ErstattungWorkflowController implements Serializable {
      
       @Begin @Create
       public Persistent init() {
       return super.init();
       }
      
       @End(ifOutcome="success")
       @Rollback(ifOutcome=Outcome.REDISPLAY)
       @CreateProcess(definition="KevlErstattung")
       public String anlegen() {
       try {
       if(check()!=null) return null;
       ((ErstattungHome)getHome()).anlegen((Erstattung) getModel());
       } catch (Throwable ex) {
       setErrorText(MessageHelper.getLabel("SaveError") + ":\n\n" + ex.getLocalizedMessage());
       return null;
       }
      
       setContextVariables();
      
       return "success";
       }
      }
      


      When a rollback is performed no exception is thrown and the same
      page is displayed as it is supposed to.

      But when I afterwards try to access the database I get a
      "javax.resource.ResourceException: Transaction is not active" and
      When I try to go to the jBPM tasklist I get a
      "javax.transaction.RollbackException: Already marked for rollback"
      (stack traces see below).

      After leaving the conversation explicitly (target="_new") everything
      is back to normal again.

      The problem occured also in Seam 1.0beta2.

      19:10:45,020 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: null
      19:10:45,030 ERROR JDBCExceptionReporter:72 - Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=null:1145984928543/20, BranchQual=null:1145984928543, localId=0:20]; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=null:1145984928543/20, BranchQual=null:1145984928543, localId=0:20])
      19:10:45,030 ERROR VersicherterHome:62 - find by criteria failed
      org.hibernate.exception.GenericJDBCException: Cannot open connection
       at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
       at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
       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:363)
       at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:122)
       at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:105)
       at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1561)
       at org.hibernate.loader.Loader.doQuery(Loader.java:661)
       at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
       at org.hibernate.loader.Loader.doList(Loader.java:2145)
       at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
       at org.hibernate.loader.Loader.list(Loader.java:2024)
       at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
       at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1552)
       at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
       at de.synthesis.kevl.dao.VersicherterHome.findByName(VersicherterHome.java:53)
       at de.synthesis.kevl.ctrl.VersicherterListController.find(VersicherterListController.java:89)
       at de.synthesis.kevl.ctrl.VersicherterListController$$EnhancerByCGLIB$$ff65bc9b.CGLIB$find$1(<generated>)
       at de.synthesis.kevl.ctrl.VersicherterListController$$EnhancerByCGLIB$$ff65bc9b$$FastClassByCGLIB$$2ca9f313.invoke(<generated>)
       at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:167)
       at org.jboss.seam.interceptors.JavaBeanInterceptor$1.proceed(JavaBeanInterceptor.java:80)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
       at org.jboss.seam.interceptors.ValidationInterceptor.validateTargetComponent(ValidationInterceptor.java:64)
       at sun.reflect.GeneratedMethodAccessor76.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:87)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
       at org.jboss.seam.interceptors.OutcomeInterceptor.interceptOutcome(OutcomeInterceptor.java:21)
       at sun.reflect.GeneratedMethodAccessor75.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:87)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
       at org.jboss.seam.interceptors.RollbackInterceptor.rollbackIfNecessary(RollbackInterceptor.java:30)
       at sun.reflect.GeneratedMethodAccessor74.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:87)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
       at org.jboss.seam.interceptors.BijectionInterceptor.bijectTargetComponent(BijectionInterceptor.java:33)
       at sun.reflect.GeneratedMethodAccessor73.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:87)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
       at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor.java:68)
       at sun.reflect.GeneratedMethodAccessor72.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:87)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
       at org.jboss.seam.interceptors.BusinessProcessInterceptor.manageBusinessProcessContext(BusinessProcessInterceptor.java:60)
       at sun.reflect.GeneratedMethodAccessor71.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:87)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
       at org.jboss.seam.interceptors.TransactionInterceptor.doInTransactionIfNecessary(TransactionInterceptor.java:34)
       at sun.reflect.GeneratedMethodAccessor70.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:87)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
       at org.jboss.seam.interceptors.RemoveInterceptor.removeIfNecessary(RemoveInterceptor.java:39)
       at sun.reflect.GeneratedMethodAccessor69.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:87)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
       at org.jboss.seam.ejb.SeamInterceptor.aroundInvokeInContexts(SeamInterceptor.java:73)
       at org.jboss.seam.ejb.SeamInterceptor.aroundInvoke(SeamInterceptor.java:45)
       at org.jboss.seam.interceptors.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:51)
       at org.jboss.seam.interceptors.JavaBeanInterceptor.intercept(JavaBeanInterceptor.java:39)
       at de.synthesis.kevl.ctrl.VersicherterListController$$EnhancerByCGLIB$$ff65bc9b.find(<generated>)
       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 com.sun.el.parser.AstValue.invoke(AstValue.java:130)
       at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
       at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
       at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)
       at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
       at javax.faces.component.UICommand.broadcast(UICommand.java:106)
       at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:95)
       at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:169)
       at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:330)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:84)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:130)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at net.sf.jguard.filters.AccessFilter.authorize(AccessFilter.java:616)
       at net.sf.jguard.filters.AccessFilter.doFilter(AccessFilter.java:369)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:23)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
       at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: org.jboss.util.NestedSQLException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=null:1145984928543/20, BranchQual=null:1145984928543, localId=0:20]; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=null:1145984928543/20, BranchQual=null:1145984928543, localId=0:20])
       at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:94)
       at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:69)
       at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:360)
       ... 121 more
      Caused by: javax.resource.ResourceException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=null:1145984928543/20, BranchQual=null:1145984928543, localId=0:20]
       at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:287)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:368)
       at org.jboss.resource.adapter.jdbc.local.LocalTxDataSource$ConnectionManagerDelegate.allocateConnection(LocalTxDataSource.java:78)
       at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:88)
       ... 123 more
      


      19:28:17,013 WARN Contexts:193 - Could not destroy component: jbpmContext
      org.hibernate.TransactionException: could not register synchronization with JTA TransactionManager
       at org.hibernate.jdbc.JDBCContext.registerSynchronizationIfPossible(JDBCContext.java:160)
       at org.hibernate.jdbc.JDBCContext.<init>(JDBCContext.java:79)
       at org.hibernate.impl.SessionImpl.<init>(SessionImpl.java:266)
       at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:436)
       at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:460)
       at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:468)
       at org.jbpm.persistence.db.DbPersistenceService.getSession(DbPersistenceService.java:90)
       at org.jbpm.JbpmContext.getSession(JbpmContext.java:354)
       at org.jboss.seam.core.ManagedJbpmContext.destroy(ManagedJbpmContext.java:102)
       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.seam.util.Reflections.invoke(Reflections.java:13)
       at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:32)
       at org.jboss.seam.contexts.Contexts.callDestroyMethod(Contexts.java:211)
       at org.jboss.seam.contexts.Contexts.destroy(Contexts.java:189)
       at org.jboss.seam.contexts.Lifecycle.flushAndDestroyContexts(Lifecycle.java:296)
       at org.jboss.seam.contexts.Lifecycle.endRequest(Lifecycle.java:221)
       at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:174)
       at org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener.afterPhase(SeamExtendedManagedPersistencePhaseListener.java:53)
       at org.apache.myfaces.lifecycle.LifecycleImpl.informPhaseListenersAfter(LifecycleImpl.java:519)
       at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:374)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:130)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at net.sf.jguard.filters.AccessFilter.authorize(AccessFilter.java:616)
       at net.sf.jguard.filters.AccessFilter.doFilter(AccessFilter.java:393)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:23)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
       at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: javax.transaction.RollbackException: Already marked for rollback, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=null:1145985933918/20, BranchQual=null:1145985933918, localId=0:20]
       at org.jboss.tm.TransactionImpl.checkStatus(TransactionImpl.java:2735)
       at org.jboss.tm.TransactionImpl.registerSynchronization(TransactionImpl.java:1528)
       at org.hibernate.jdbc.JDBCContext.registerSynchronizationIfPossible(JDBCContext.java:149)
       ... 50 more