[jboss-user] [JBoss jBPM] - Adding timer issue
TheEJBPope
do-not-reply at jboss.com
Thu Nov 23 09:44:07 EST 2006
Hi,
As a number of posters of this forum I'm trying to create a timer in my node action handler. When the timer expires, it should push the process along the "time-out" transition. And that's it. But I can't make it work. Even after an extensive look to the documentation and forums...
Having seen a number of code examples in this forum, I imitated it:
| Duration duration = new Duration(timeout/1000 + " seconds");
| BusinessCalendar businessCalendar = new BusinessCalendar();
| Date dueDate = businessCalendar.add(new Date(), duration);
| Timer timer = new Timer( executionContext.getToken() );
| timer.setName( name );
| timer.setDueDate( dueDate );
| timer.setTransitionName( transitionName );
| timer.setGraphElement( executionContext.getEventSource() );
| timer.setTaskInstance( executionContext.getTaskInstance() );
| timer.setAction();
| SchedulerService schedulerService = (SchedulerService) Services.getCurrentService( Services.SERVICENAME_SCHEDULER );
| schedulerService.createTimer( timer );
|
The process is kicked-off without any problem, but when the timer expires I'm getting the exception described underneath:
| 15:31:17,677 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: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
| at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
| at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46)
| at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)
| at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
| at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
| at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
| at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:144)
| 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.close(DbPersistenceService.java:162)
| ... 4 more
| 15:31:17,679 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: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
| at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
| at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46)
| at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)
| at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
| at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
| at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
| at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:144)
| 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.close(DbPersistenceService.java:162)
| ... 4 more
|
I've had a look into the JBPM_TIMER table; compared to a timer created from the process definition. With strikes me is that the columns for the action, graph element type and graph element are null. While the row for the timer created with the process definition has values for it.
Modifying the code sample as follows does fill in the graph element columns:
| timer.setGraphElement( executionContext.getEventSource() );
| replaced by
| timer.setGraphElement( executionContext.getNode() );
|
(getEventSource() is always null for me by the way...)
The action column remains empty though. And setting an action to the timer with the Timer.setAction( Action ) method results in the next exception:
15:27:54,517 ERROR [STDERR] org.jbpm.JbpmException: problem closing services {persistence=org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session}
| 15:27:54,518 ERROR [STDERR] at org.jbpm.svc.Services.close(Services.java:223)
| 15:27:54,518 ERROR [STDERR] at org.jbpm.JbpmContext.close(JbpmContext.java:139)
| 15:27:54,518 ERROR [STDERR] at com.luciad.oldi.server.ejb.messagebroker.TLcdOLDIMessageBroker.onMessage(TLcdOLDIMessageBroker.java:160)
| 15:27:54,518 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| 15:27:54,518 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| 15:27:54,518 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| 15:27:54,519 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
| 15:27:54,519 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
| 15:27:54,519 ERROR [STDERR] at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
| 15:27:54,519 ERROR [STDERR] at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
| 15:27:54,519 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| 15:27:54,519 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
| 15:27:54,519 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| 15:27:54,519 ERROR [STDERR] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
| 15:27:54,520 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| 15:27:54,520 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInNoTx(TxPolicy.java:66)
| 15:27:54,520 ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Never.invoke(TxInterceptor.java:65)
| 15:27:54,520 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| 15:27:54,520 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
| 15:27:54,520 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| 15:27:54,520 ERROR [STDERR] at org.jboss.ejb3.mdb.MessagingContainer.localInvoke(MessagingContainer.java:245)
| 15:27:54,520 ERROR [STDERR] at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.delivery(MessageInflowLocalProxy.java:268)
| 15:27:54,521 ERROR [STDERR] at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.invoke(MessageInflowLocalProxy.java:138)
| 15:27:54,521 ERROR [STDERR] at $Proxy72.onMessage(Unknown Source)
| 15:27:54,521 ERROR [STDERR] at org.jboss.resource.adapter.jms.inflow.JmsServerSession.onMessage(JmsServerSession.java:183)
| 15:27:54,521 ERROR [STDERR] at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:905)
| 15:27:54,521 ERROR [STDERR] at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:170)
| 15:27:54,521 ERROR [STDERR] at org.jboss.mq.SpySession.run(SpySession.java:323)
| 15:27:54,521 ERROR [STDERR] at org.jboss.resource.adapter.jms.inflow.JmsServerSession.run(JmsServerSession.java:249)
| 15:27:54,521 ERROR [STDERR] at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:204)
| 15:27:54,522 ERROR [STDERR] at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:275)
| 15:27:54,522 ERROR [STDERR] at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)
| 15:27:54,522 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
| 15:27:54,522 ERROR [STDERR] Caused by: org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session
| 15:27:54,522 ERROR [STDERR] at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:172)
| 15:27:54,522 ERROR [STDERR] at org.jbpm.svc.Services.close(Services.java:211)
| 15:27:54,522 ERROR [STDERR] ... 32 more
| 15:27:54,522 ERROR [STDERR] Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: org.jbpm.graph.def.Action
| 15:27:54,523 ERROR [STDERR] at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
| 15:27:54,523 ERROR [STDERR] at org.hibernate.type.EntityType.getIdentifier(EntityType.java:108)
| 15:27:54,523 ERROR [STDERR] at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:242)
| 15:27:54,523 ERROR [STDERR] at org.hibernate.type.TypeFactory.findDirty(TypeFactory.java:482)
| 15:27:54,523 ERROR [STDERR] at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:3056)
| 15:27:54,523 ERROR [STDERR] at org.hibernate.event.def.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:474)
| 15:27:54,523 ERROR [STDERR] at org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:197)
| 15:27:54,523 ERROR [STDERR] at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:120)
| 15:27:54,524 ERROR [STDERR] at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:196)
| 15:27:54,524 ERROR [STDERR] at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
| 15:27:54,524 ERROR [STDERR] at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
| 15:27:54,524 ERROR [STDERR] at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
| 15:27:54,524 ERROR [STDERR] at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
| 15:27:54,524 ERROR [STDERR] at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
| 15:27:54,524 ERROR [STDERR] at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:162)
| 15:27:54,524 ERROR [STDERR] ... 33 more
|
I'm probably making this way too complex. For just creating a timer with an empty action... I've had an extensive look to the documentation and forum, but I obviously missed the catch. Can anybody help me further with this please ?
The only thing I'm wanting to achieve is setting a timer with a dynamic duedate. If sombody knows how I can modify the duedate of a timer mentioned in the process definition, that would be just fine too...
I'm using JBPM 3.1.2, with the web app of the starter's kit, deployed on a JBoss 4.0.5GA application server. J2SE 1.5.
Many thanks for any clue !
Jan
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3988184#3988184
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3988184
More information about the jboss-user
mailing list