3 Replies Latest reply on Jul 13, 2007 12:03 PM by kukeltje

    Cancel a process in a repeated action

    vbub

      i'm starting the execution of an action 5 seconds after entering a task node. this action repeatedly checks a state in a third party application and eventually shall cancel the whole process instance.

      i'm trying to do this by using this code:

      CancelProcessInstanceCommand cpic = new CancelProcessInstanceCommand(task.getProcessInstance().getId());
      cpic.setCancelSubProcesses(true);
      CommandServiceImpl csi = new CommandServiceImpl(jbpmConfiguration);
      csi.execute(cpic);


      i get the following error (running with postgreSQL on apache tomcat):

      12:38:46,520 ERROR [168.0.18:1] JobExecutorThread : exception in job executor thread. waiting 2500 milliseconds
      org.jbpm.JbpmException: problem closing services {persistence=org.jbpm.persistence.JbpmPersistenceException: hibernate commit failed}
       at org.jbpm.svc.Services.close(Services.java:235)
       at org.jbpm.JbpmContext.close(JbpmContext.java:139)
       at org.jbpm.job.executor.JobExecutorThread.executeJob(JobExecutorThread.java:181)
       at org.jbpm.job.executor.JobExecutorThread.run(JobExecutorThread.java:62)
      Caused by: org.jbpm.persistence.JbpmPersistenceException: hibernate commit failed
       at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:216)
       at org.jbpm.svc.Services.close(Services.java:222)
       ... 3 more
      Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.jbpm.job.Timer#683]
       at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1765)
       at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2407)
       at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2307)
       at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2607)
       at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
       at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)
       at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
       at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
       at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
       at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
       at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
       at org.jbpm.persistence.db.DbPersistenceService.commit(DbPersistenceService.java:253)
       at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:211)
       ... 4 more
      
      i've read about the concept of executing the commands asynchronously but it seems the CommandServiceImpl executes the CancelProcessInstanceCommand immediately (when my action, called out of the JobExecutor/Timer is still active)... i'm not sure how to solve this and haven't found a thread or solution in this forum yet that seem to fit my problem.
      
      thank you very much,
      volker


        • 1. Re: Cancel a process in a repeated action
          vbub

          please let me know if i shall contribute more info that is helpful. i'm not sure where to look for a reason of this problem so i need some sort of hint here. thank you very much.

          • 2. Re: Cancel a process in a repeated action
            vbub

            ok, i just wanted to post that i solved my problem. I just have to make sure that i use the jbpmContext out of the executionContext of my action.

            CancelProcessInstanceCommand cpic = new CancelProcessInstanceCommand(task.getProcessInstance().getId());
             cpic.setCancelSubProcesses(true);
             try {
             cpic.execute(executionContext.getJbpmContext());
             } catch (Exception e) {
             // what ever...
             }




            • 3. Re: Cancel a process in a repeated action
              kukeltje

              ahh... you tried to cancel a SUB-process from an action. I see that the post I (thought I) made did not come through. Cancelling a process from an action in this specific process is not done (afaik)

              Thanks for letting us know the solution