1 Reply Latest reply on Nov 27, 2006 8:19 AM by Jim Knopf

    Timer ; exception ; Hibernate

    Jim Knopf Newbie

      Hi again,

      I have a Timer and let it execute an action.
      After the Timer execute the Action i got a Exception when the TimerThread want to close his JBPMContext.
      Can some one help and tell me what's wrong?

      Processdefinition:

      String processDefinition = "<process-definition name='Timos die erste'>" + " <swimlane name='ingo'>"
       + " <assignment expression='user(ingo)'></assignment>" + " </swimlane>"
      
       + " <swimlane name='tanja'>" + " <assignment expression='user(tanja)'></assignment>"
       + " </swimlane>"
      
       + " <start-state name='start'>" + " <transition name='transition 1' to='tasknode1' />"
       + " </start-state>"
      
       + " <task-node name='tasknode1'>" + " <task name='Test Tasknote1' swimlane='tanja'>"
       + " <timer name='ContentExpired' duedate='3 seconds' transition='timeUp' >"
       + " <action class='actions.actionTest2'>" + " </action>" + " </timer>" + " <controller>"
       + " <variable name='age' access='read,write'></variable>"
       + " <variable name='age1' access='read'></variable>"
       + " <variable name='age11' access='read'></variable>"
       + " <variable name='age111' access='read,write'></variable>"
       + " <variable name='age1111' access='read,write'></variable>"
       + " <variable name='age11111' access='read'></variable>"
       + " <variable name='age111111' access='read'></variable>"
       + " <variable name='age1111111' access='read,write'></variable>"
       + " <variable name='age11111111' access='read,write'></variable>"
       + " <variable name='age111111111' access='read,write'></variable>" + " </controller>"
       + " </task>" + " <transition name='transition 2' to='tasknode2'></transition>"
       + " <transition name='timeUp' to='end'></transition>" + " </task-node>"
      
       + " <task-node name='tasknode2'>" + " <task name='Test Tasknote2' swimlane='tanja'>"
       + " <controller>" + " <variable name='age' access='read,write,required'></variable>"
       + " </controller>" + " </task>" + " <transition name='transition 22' to='Timo 1'></transition>"
       + " </task-node>"
      
       + " <state name='Timo 1'>" + " <transition name='transition 3' to='end'/>" + " </state>"
      
       + " <end-state name='end' />" + "</process-definition>";
      


      The Schedular:
       private void initSchedular () {
       // java SchedulerMain <interval> <historyMaxSize> <dateFormat>
      
       // create a new scheduler
       Scheduler scheduler = new Scheduler();
      
       // initialize it with the command line parameters
       int interval = 5000;
       scheduler.setInterval(interval);
       int historyMaxSize = 50;
       scheduler.setHistoryMaxSize(historyMaxSize);
       DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
      
       // start the scheduler
       scheduler.start();
      
       // register the console listener
       scheduler.getSchedulerThread().addListener( new LogListener(dateFormat) );
       }
      


      The Exception

      09:13:48,375 [JbpmScheduler] DEBUG JbpmContextInfo : creating jbpm context with service factories '[message, scheduler, authentication, persistence, logging]'
      09:13:48,375 [JbpmScheduler] DEBUG JbpmContext : creating JbpmContext
      09:13:48,375 [JbpmScheduler] DEBUG DbPersistenceServiceFactory : creating persistence service
      09:13:48,375 [JbpmScheduler] DEBUG DbPersistenceService : creating hibernate session
      09:13:48,375 [JbpmScheduler] DEBUG DbPersistenceService : beginning hibernate transaction
      09:13:48,375 [JbpmScheduler] DEBUG SchedulerThread : checking for timers
      My Timer-Action!
      09:13:48,406 [JbpmScheduler] DEBUG SchedulerThread : found timer timer(ContentExpired,actions.actionTest2,09:13:48,047)
      09:13:48,406 [JbpmScheduler] DEBUG SchedulerThread : executing timer 'timer(ContentExpired,actions.actionTest2,09:13:48,047)'
      09:13:48,421 [JbpmScheduler] DEBUG Timer : executing timer 'timer(ContentExpired,actions.actionTest2,09:13:48,047)'
      09:13:48,421 [JbpmScheduler] DEBUG GraphElement : event 'before-signal' on 'TaskNode(tasknode1)' for 'Token(/)'
      09:13:48,421 [JbpmScheduler] DEBUG GraphElement : event 'node-leave' on 'TaskNode(tasknode1)' for 'Token(/)'
      09:13:48,421 [JbpmScheduler] DEBUG GraphElement : event 'transition' on 'Transition(timeUp)' for 'Token(/)'
      09:13:48,437 [JbpmScheduler] DEBUG GraphElement : event 'node-enter' on 'EndState(end)' for 'Token(/)'
      09:13:48,437 [JbpmScheduler] DEBUG GraphElement : event 'process-end' on 'ProcessDefinition(Timos die erste)' for 'Token(/)'
      09:13:48,453 [JbpmScheduler] DEBUG GraphElement : event 'after-signal' on 'TaskNode(tasknode1)' for 'Token(/)'
      09:13:48,453 [JbpmScheduler] DEBUG Services : executing default save operations
      09:13:48,453 [JbpmScheduler] DEBUG HibernateSaveOperation : saving process instance
      09:13:48,453 [JbpmScheduler] DEBUG SaveLogsOperation : flushing logs to logging service.
      09:13:48,468 [JbpmScheduler] DEBUG CascadeSaveOperation : cascading save of 'org.jbpm.graph.exe.ProcessInstance@11a6631'
      09:13:48,468 [JbpmScheduler] INFO TestFrame$LogListener : 23/11/2006 09:13:48 | timer(ContentExpired,actions.actionTest2,09:13:48,047) | OK |
      09:13:48,468 [JbpmScheduler] DEBUG SchedulerThread : deleting timer 'timer(ContentExpired,actions.actionTest2,09:13:48,047)'
      09:13:48,468 [JbpmScheduler] DEBUG JbpmContext : closing JbpmContext
      09:13:48,468 [JbpmScheduler] DEBUG Services : closing service 'persistence': org.jbpm.persistence.db.DbPersistenceService@1c7510d
      09:13:48,468 [JbpmScheduler] DEBUG DbPersistenceService : committing hibernate transaction
      09:13:48,484 [JbpmScheduler] ERROR AbstractFlushingEventListener : Could not synchronize database state with session
      org.hibernate.StaleStateException: Unexpected row count: 0 expected: 1
      at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:27)
      at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2291)
      at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2440)
      at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:65)
      at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:145)
      at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980)
      at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:353)
      at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
      at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:162)
      at org.jbpm.svc.Services.close(Services.java:211)
      at org.jbpm.JbpmContext.close(JbpmContext.java:139)
      at org.jbpm.scheduler.impl.SchedulerThread.executeTimers(SchedulerThread.java:161)
      at org.jbpm.scheduler.impl.SchedulerThread.run(SchedulerThread.java:70)
      org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session
      at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:172)
      at org.jbpm.svc.Services.close(Services.java:211)
      at org.jbpm.JbpmContext.close(JbpmContext.java:139)
      at org.jbpm.scheduler.impl.SchedulerThread.executeTimers(SchedulerThread.java:161)
      at org.jbpm.scheduler.impl.SchedulerThread.run(SchedulerThread.java:70)
      Caused by: org.hibernate.StaleStateException: Unexpected row count: 0 expected: 1
      at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:27)09:13:48,500 [JbpmScheduler] ERROR Services : problem closing service 'persistence'
      org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session
      at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:172)
      at org.jbpm.svc.Services.close(Services.java:211)
      at org.jbpm.JbpmContext.close(JbpmContext.java:139)
      at org.jbpm.scheduler.impl.SchedulerThread.executeTimers(SchedulerThread.java:161)
      at org.jbpm.scheduler.impl.SchedulerThread.run(SchedulerThread.java:70)
      Caused by: org.hibernate.StaleStateException: Unexpected row count: 0 expected: 1
      at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:27)
      at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2291)
      at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2440)
      at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:65)
      at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:145)
      at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980)
      at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:353)
      at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
      at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:162)
      ... 4 more
      09:13:48,500 [JbpmScheduler] DEBUG Services : closing service 'scheduler': org.jbpm.scheduler.db.DbSchedulerService@c524dd
      09:13:48,500 [JbpmScheduler] DEBUG Services : closing service 'logging': org.jbpm.logging.db.DbLoggingService@f757b9
      09:13:48,500 [JbpmScheduler] INFO SchedulerThread : runtime exception while executing timers
      org.jbpm.JbpmException: problem closing services {persistence=org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session}
      at org.jbpm.svc.Services.close(Services.java:223)
      at org.jbpm.JbpmContext.close(JbpmContext.java:139)
      at org.jbpm.scheduler.impl.SchedulerThread.executeTimers(SchedulerThread.java:161)
      at org.jbpm.scheduler.impl.SchedulerThread.run(SchedulerThread.java:70)
      Caused by: org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session
      at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:172)
      at org.jbpm.svc.Services.close(Services.java:211)
      ... 3 more
      Caused by: org.hibernate.StaleStateException: Unexpected row count: 0 expected: 1
      at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:27)
      at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2291)
      at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2440)
      at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:65)
      at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:145)
      at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980)
      at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:353)
      at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
      at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:162)
      ... 4 more

      at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2291)
      at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2440)
      at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:65)
      at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:145)
      at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980)
      at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:353)
      at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
      at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:162)
      ... 4 more






        • 1. Re: Timer ; exception ; Hibernate
          Jim Knopf Newbie

          The Timer definition and the definition of the Transaction were not in the same block.

          Now it is working.

           + " <task-node name='tasknode1'>"
           + " <timer name='ContentExpired' duedate='20 seconds' transition='timeUp'>"
           + " <action class='actions.actionTest2'>"
           + " </action>"
           + " </timer>"
           + " <task name='Test Tasknote1' swimlane='tanja'>"
           + " <controller>"
           + " <variable name='age' access='read,write'></variable>"
           + " <variable name='age1' access='read'></variable>"
           + " <variable name='age11' access='read'></variable>"
           + " <variable name='age111' access='read,write'></variable>"
           + " <variable name='age1111' access='read,write'></variable>"
           + " <variable name='age11111' access='read'></variable>"
           + " <variable name='age111111' access='read'></variable>"
           + " <variable name='age1111111' access='read,write'></variable>"
           + " <variable name='age11111111' access='read,write'></variable>"
           + " <variable name='age111111111' access='read,write'></variable>"
           + " </controller>"
           + " </task>"
           + " <transition name='transition 2' to='tasknode2'></transition>"
           + " <transition name='timeUp' to='tasknode2'></transition>"
           + " </task-node>"