Problem in
robyf May 9, 2006 6:36 AMHi,
I'm using jbpm in a process where I have many tokens running and two main difference kinds of node:
- "internal activities node": implemented as general purpose node (no Task) that represent some activities (routine, maybe task, etc...)
- "receiver node" that wait for external input; when one of this node has to be activated (the external input go in) I load (jbpmContext.load) my token and signaling it.
It happen that sometimes when I receive an input addressed to a receiver node my process execution is active through a different token.
My input are input from the Web ... so to each input I have a new java Thread
I found a solution to synchronize the control flow of process (implementing a custom sort of join), but I have problem with the persistence... I mean ...
When I receive an input to a receiver node I do the following:
(2) load the process
(3) signal
(4) save the processInstance (I didn't found a method to really save just a token)
(5) close the jbpmContext
It sometime happens that I receive two input for two different receivers nodes in a short time gap ... and for instance when I've done (1)-(2)-(3)- (4) for input A, before doing (5) , I do (1) and (2)-(3)-(4) for input B (my VM decide for me :) ). When my B thread then arrive to (5) [close the jbpmcontext] I have the following error:
[#|2006-05-09T10:03:18.880+0200|SEVERE|sun-appserver-pe8.2|org.hibernate.event.def.AbstractFlushingEventListener|_ThreadID=19;|Could not synchronize database state with session
org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.jbpm.graph.exe.Token#130842624]
at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1635)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2208)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:84)
.........
I have two java thread of execution and I think that happens something like the following:
| >>Thread A | >>>> Thread B
------------------------------------------------
I) openJbpmContex
II) load
III) signal
IV) save
V) --------------------- openJbpmContex
VI)--------------------- load
VII) ------------------- signal
VIII) ------------------ save
IX)-------------------- close >> ERROR
I'm using Jbpm inside a J2EE netBeans project under Sun Application Server, but I think that's not due to the environment ...
Maybe I'm not using in the right wait the persistence tool ... I ask you sorry if this is the case ...
Do you have any suggestion to manage and solve this problem???
I'm doing something wrong??
Thanks in advance.
Roby.