1 Reply Latest reply on Apr 22, 2006 1:58 PM by koen.aers

    Calling SaveProcessInstance from a SchedulerSession

    brianmb99

      Hi all,

      I'm having a bit of difficulty with timers and saving the process instance. I'm using version 3.0.2.

      If a timer is executed by the Scheduler and during the workflow execution initiated by this timer I call

      JbpmSession.getCurrentJbpmSession().getGraphSession().saveProcessInstance(pi)

      then when the token finally comes to a wait state, the GraphSession, whose Hibernate session is apparently not related to the Hibernate session of the Scheduler, has already deleted the Timer. So when the Scheduler tries to delete the timer I get:

      20 April 2006 20:17:54,976 DEBUG [AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 3, globally: 3)
      20 April 2006 20:17:54,976 DEBUG [SQL] delete from JBPM_TIMER where ID_=?
      20 April 2006 20:17:54,976 DEBUG [AbstractBatcher] preparing statement
      20 April 2006 20:17:54,976 DEBUG [LongType] binding '4678' to parameter: 1
      20 April 2006 20:17:54,976 DEBUG [AbstractBatcher] Adding to batch
      20 April 2006 20:17:54,976 DEBUG [AbstractBatcher] Executing batch size: 1
      20 April 2006 20:17:54,992 ERROR [AbstractBatcher] Exception executing batch:
      org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
       at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:92)
       at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:78)
       at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
       at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:172)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
       at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
       at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
       at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:716)
       at org.jbpm.db.JbpmSession.commitTransaction(JbpmSession.java:104)
       at org.jbpm.db.JbpmSession.commitTransactionAndClose(JbpmSession.java:131)
       at org.jbpm.scheduler.impl.SchedulerThread.executeTimers(SchedulerThread.java:121)
       at org.jbpm.scheduler.impl.SchedulerThread.run(SchedulerThread.java:34)


      and the entire transaction rolls back.

      I don't know a lot about Hibernate, so I hope I'm making sense. The only way I've found to prevent this from happening is to forego saving the ProcessInstance, which means I don't get the detailed logging.

      Anyone else had this problem or have any ideas for me?

      Thanks!