cancelTimersForProcessInstance fails if process is not saved
kukeltje Jun 2, 2006 8:27 AMEnv:
- jBPM 3.1.1
- jdk 1.5.0_06
- windows xpsp2
We are (ab)using jbpm (jpdl) for a stp service where we eventually will use jbpm bpel. It is a process witrh custom nodes which do sync or async calls to an ESB (Mule). There are no wait states so this means the processInstance is signalled and right before the signal method gets back the process is in fact ended.
On calling the ProcessInstance.end(), all timers are being cancelled. This fails
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:108)
at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:221)
at org.hibernate.type.TypeFactory.findDirty(TypeFactory.java:476)
at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:2802)
at org.hibernate.event.def.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:457)
at org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:180)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:104)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.prepareQueries(SessionImpl.java:1071)
at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1061)
at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1041)
at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:89)
at org.jbpm.db.SchedulerSession.cancelTimersForProcessInstance(SchedulerSession.java:169)
at org.jbpm.scheduler.db.DbSchedulerService.cancelTimersByProcessInstance(DbSchedulerService.java:55)
at org.jbpm.graph.exe.ProcessInstance.end(ProcessInstance.java:275)
...
...
The cause is that
public void cancelTimersForProcessInstance(ProcessInstance processInstance) { try { Query query = session.getNamedQuery("SchedulerSession.deleteTimersForProcessInstance"); query.setEntity("processInstance", processInstance); query.executeUpdate(); } catch (Exception e) { log.error(e); jbpmSession.handleException(); throw new JbpmException("couldn't delete timers for process instance '"+processInstance+"'", e); } }
fails in the following hibernate query
<query name="SchedulerSession.deleteTimersForProcessInstance"> <![CDATA[ delete from org.jbpm.scheduler.exe.Timer t where t.processInstance = :processInstance ]]> </query>
Which is 'logical' since the processinstances is not saved yet in any way. So the hibernate exception is valid.
Introducing a state where we save the process and signal it again to do the real work works, but that is not what we want.
Any tips/hints?
btw, to be comlete so David will not answer with the link, here is my custom node:
package net.vankuijk.jbpm.customNode; import org.jbpm.graph.def.ActionHandler; import org.jbpm.graph.exe.ExecutionContext; public class MyNode implements ActionHandler { public void execute(ExecutionContext executionContext) throws Exception { executionContext.leaveNode(); } }
and my process:
<?xml version="1.0" encoding="UTF-8"?> <process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="customNode"> <start-state name="start"> <transition name="node1" to="node1"></transition> </start-state> <node name="node1"> <action class="nl.vankuijk.jbpm.customNode.MyNode" </action> <transition name="to_end" to="end"></transition> </node> <end-state name="end"></end-state> </process-definition>