Concurrency Problem
wjn811 Jun 17, 2009 11:04 PMHi guys,
I am a poor java developer... and I'm on my way pushing myself to learn more.
I met a problem when I use jBPM4.0CR1.
The problem is described as following,
My boss asked me to make a workflow, which mainly contains 2 concurrency flows. And unfortunately, one is contained in another...
That means, a super process has a 'Con1' fork activity. And among the executions under that 'Con1', there is a sub-process, which also contains another fork activity 'Con2'.
Here is jpdls, (concurrency.jpdl.xml & sub_concurrency.jpdl.xml)
I hope you will understand what I am talking about~
concurrency.jpdl.xml
<process name="concurruncy" xmlns="http://jbpm.org/4.0/jpdl"> <start g="13,103,48,48" name="start1"> <transition g="-52,-22" name="to fork1" to="fork1"/> </start> <end g="818,27,48,48" name="end1"/> <fork g="100,101,48,48" name="fork1"> <transition g="-52,-22" name="to task1" to="task1"/> <transition name="to task2" to="task2" g="-52,-22"/> </fork> <task assignee="#{u1}" g="240,145,92,52" name="task1"> <transition g="-56,-21" name="to Subprocess1" to="Subprocess1"/> </task> <task assignee="#{u2}" g="223,12,92,52" name="task2"> <transition g="-49,-22" name="to join2" to="join2"/> </task> <join g="681,26,48,48" name="join2"> <transition g="-50,-22" name="to end1" to="end1"/> </join> <sub-process g="420,139,92,52" name="Subprocess1" sub-process-key="sub_concurrency"> <parameter-in subvar="u2" var="u2"/> <parameter-in subvar="u4" var="u4"/> <transition g="-49,-22" name="to join2" to="join2"/> </sub-process> </process>
sub_concurrency.jpdl.xml
<process name="sub_concurrency" xmlns="http://jbpm.org/4.0/jpdl"> <start g="89,110,48,48" name="start1"> <transition g="-52,-22" name="to fork1" to="fork1"/> </start> <end g="596,115,48,48" name="sub_end"/> <fork g="200,107,48,48" name="fork1"> <transition g="-52,-22" name="to task4" to="task4"/> <transition name="to task3" to="task3" g="-52,-22"/> </fork> <task assignee="#{u3}" g="304,60,92,52" name="task3"> <transition g="-28,-25" name="to sub_join" to="sub_join"/> </task> <task assignee="#{u4}" g="309,150,92,52" name="task4"> <transition g="-27,3" name="to sub_join" to="sub_join"/> </task> <join g="483,113,48,48" name="sub_join"> <transition g="-36,-25" name="to sub_end" to="sub_end"/> </join> </process>
I'm sorry. I apply these nonsense names on assignees and task names :)
I make a JUnit test to run this work flow.
Then, java exceptions appears,
10:46:30,185 FIN | [Execution] execution[to task4] ends 10:46:30,187 FIN | [Execution] execution[to task3] ends 10:46:30,187 FIN | [ExecuteActivity] executing activity(sub_end) 10:46:30,188 FIN | [Execution] process-instance ends with state ended 10:46:30,203 FIN | [Signal] execution[to task1] signals activity(Subprocess1) 10:46:30,204 WRN | [ProxyWarnLog] Narrowing proxy to class org.jbpm.jpdl.internal.model.JpdlExecution - this operation breaks == 10:46:30,204 FIN | [ExecuteActivity] execution[to task1] executes activity(join2) 10:46:30,213 FIN | [Execution] execution[to task1] ends 10:46:30,215 FIN | [Execution] execution[to task2] ends 10:46:30,215 FIN | [ExecuteActivity] executing activity(end1) 10:46:30,215 FIN | [Execution] process-instance ends with state ended 10:46:30,228 WRN | [JDBCExceptionReporter] SQL Error: 1451, SQLState: 23000 10:46:30,229 SEV | [JDBCExceptionReporter] Cannot delete or update a parent row: a foreign key constraint fails (`jbpm4db/jbpm4_execution`, CONSTRAINT `FK_EXEC_SUPEREXEC` FOREIGN KEY (`SUPEREXEC_`) REFERENCES `jbpm4_execution` (`DBID_`)) ### EXCEPTION ########################################### 10:46:30,229 SEV | [AbstractFlushingEventListener] Could not synchronize database state with session org.hibernate.exception.ConstraintViolationException: could not delete: [org.jbpm.jpdl.internal.model.JpdlExecution#2] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2569) at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2725) at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:97) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:172) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321) at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:64) at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:996) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1141) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102) at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:835) at org.jbpm.pvm.internal.hibernate.DbSessionImpl.findProcessInstanceById(DbSessionImpl.java:175) at org.jbpm.pvm.internal.hibernate.DbSessionImpl.deleteProcessInstance(DbSessionImpl.java:225) at org.jbpm.pvm.internal.model.ExecutionImpl.end(ExecutionImpl.java:354) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197) at org.jbpm.pvm.internal.model.ExecutionImpl_$$_javassist_3.end(ExecutionImpl_$$_javassist_3.java) at org.jbpm.pvm.internal.model.ExecutionImpl.end(ExecutionImpl.java:364) at org.jbpm.jpdl.internal.activity.EndActivity.execute(EndActivity.java:82) at org.jbpm.jpdl.internal.activity.EndActivity.execute(EndActivity.java:45) at org.jbpm.pvm.internal.model.op.ExecuteActivity.perform(ExecuteActivity.java:60) at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperationSync(ExecutionImpl.java:625) at org.jbpm.pvm.internal.model.ExecutionImpl.fire(ExecutionImpl.java:535) at org.jbpm.pvm.internal.model.ExecutionImpl.take(ExecutionImpl.java:441) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197) at org.jbpm.pvm.internal.model.ExecutionImpl_$$_javassist_3.take(ExecutionImpl_$$_javassist_3.java)
I find that all the execution has been well finished and inactive executions will be deleted from jbpm4_exection
10:53:39,305 FIN | [ExecuteActivity] execution[to task1] executes activity(join2) 10:53:39,311 FIN | [Execution] execution[to task1] ends 10:53:39,314 FIN | [Execution] execution[to task2] ends 10:53:39,314 FIN | [ExecuteActivity] executing activity(end1) 10:53:39,314 FIN | [Execution] process-instance ends with state ended
But failed because of foreign key constraint. I dont know why...
Do I make the problem clearly described?
Please help me~ Thx!
My mail: crazydog.eric@gmail.com
-----------------------------------------------------
And I find that if I add a state activity just after sub-process, which will join together with task2, things go right! Is it a kind of answer?