0 Replies Latest reply on Sep 7, 2006 10:09 PM by Amit Sachde

    End a long running process from a page flow

    Amit Sachde Newbie

      I have a pageflow which calls a SSB (derivative of todo example) and when I call the done method I get IllegalStateException ... cannot call Start from a long running transaction ... call @Begin(join=true) etc...

      So I changed the done method (Instead of @BeginTask(taskIdParameter="taskId") @EndTask) to use the following code:
      String l = (String) org.jboss.seam.Component.getRequestParameters().get("taskId");
      long tid= Long.parseLong(l);
      JbpmContext jbpm = JbpmConfiguration.getInstance().createJbpmContext();

      try {
      TaskInstance ti = jbpm.loadTaskInstance(tid);
      ti.end();
      } finally {
      jbpm.close();
      System.out.println("Maybe the process ended!!!");
      }

      The first time I call the method I get the following exception. The process ends but get the nasty stack trace on the page instead of following the page flow. If I hit back and create new long running processes and stop them I dont get any errors.

      If I use RequestParameter("taskId") then any other method I call on the SSB throws an exception cannot set taskId on SSB!

      What am I doing wrong.

      See stack trace below:
      21:57:40,735 INFO [STDOUT] Async-process ended!!!
      21:57:40,755 INFO [STDOUT] The process definately ended!!!
      21:57:40,775 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
      org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was
      incorrect): [org.jbpm.graph.exe.Token#12]
      at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1680)
      at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2272)
      at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2180)
      at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2450)
      at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:91)
      at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
      at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:29
      7)
      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:993)
      at org.jboss.seam.core.ManagedJbpmContext.beforeCompletion(ManagedJbpmContext.java:90)
      at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1491)
      at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1110)
      at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:324)
      at org.jboss.tm.TxManager.commit(TxManager.java:240)
      at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140)
      at org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener.commitOrRollback(SeamExtendedManagedPersistenc
      ePhaseListener.java:87)
      at org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener.afterPageActions(SeamExtendedManagedPersistenc
      ePhaseListener.java:61)
      at org.jboss.seam.jsf.AbstractSeamPhaseListener.callPageActions(AbstractSeamPhaseListener.java:137)
      at org.jboss.seam.jsf.AbstractSeamPhaseListener.beforeRender(AbstractSeamPhaseListener.java:98)
      at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:50)
      at org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener.beforePhase(SeamExtendedManagedPersistencePhas
      eListener.java:38)
      at org.apache.myfaces.lifecycle.LifecycleImpl.informPhaseListenersBefore(LifecycleImpl.java:520)
      at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:342)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:30)
      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.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      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.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      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.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      at java.lang.Thread.run(Thread.java:595)
      21:57:41,026 ERROR [SeamExceptionFilter] uncaught exception handled by Seam
      javax.servlet.ServletException: Could not commit transaction
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:121)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:30)
      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.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      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.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      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.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      at java.lang.Thread.run(Thread.java:595)
      21:57:41,146 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
      java.lang.IllegalStateException: Could not commit transaction
      at org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener.commitOrRollback(SeamExtendedManagedPersistenc
      ePhaseListener.java:98)
      at org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener.afterPageActions(SeamExtendedManagedPersistenc
      ePhaseListener.java:61)
      at org.jboss.seam.jsf.AbstractSeamPhaseListener.callPageActions(AbstractSeamPhaseListener.java:137)
      at org.jboss.seam.jsf.AbstractSeamPhaseListener.beforeRender(AbstractSeamPhaseListener.java:98)
      at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:50)
      at org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener.beforePhase(SeamExtendedManagedPersistencePhas
      eListener.java:38)
      at org.apache.myfaces.lifecycle.LifecycleImpl.informPhaseListenersBefore(LifecycleImpl.java:520)
      at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:342)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:30)
      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.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      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.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      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.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      at java.lang.Thread.run(Thread.java:595)
      Caused by: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=amit
      s-066229/88, BranchQual=, localId=88] status=STATUS_NO_TRANSACTION; - nested throwable: (org.hibernate.StaleObjectStateE
      xception: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.jbpm.graph.ex
      e.Token#12])
      at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:372)
      at org.jboss.tm.TxManager.commit(TxManager.java:240)
      at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140)
      at org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener.commitOrRollback(SeamExtendedManagedPersistenc
      ePhaseListener.java:87)
      ... 32 more
      Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value
      mapping was incorrect): [org.jbpm.graph.exe.Token#12]
      at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1680)
      at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2272)
      at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2180)
      at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2450)
      at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:91)
      at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
      at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:29
      7)
      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:993)
      at org.jboss.seam.core.ManagedJbpmContext.beforeCompletion(ManagedJbpmContext.java:90)
      at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1491)
      at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1110)
      at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:324)
      ... 35 more