Details
Description
I came across an issue while completing simple user task from the parallel gateway that contains a task with task listener.
Here are the steps to repro:
1. Create a TaskListener implementation that sets local variable on task creation
[code]private Expression expression;
public void notify(DelegateTask delegateTask)
{ String expression = this.expression.getValue(delegateTask).toString(); delegateTask.setVariableLocal("validationRule", expression); }[/code]
2. In bpmn xml file, create a parallel gateway with 2 outgoing tasks: a simple user task and a user task with task listener created in step 1
3. Deploy process definition
4. Run the process
5. Attempt to complete the simple user task programmatically
[code]TaskService taskService = getProcessEngine().getTaskService();
taskService.complete(taskId);
[/code]
6. Get the following stack trace:
[code]### Error updating database. Cause: java.sql.SQLException: The DELETE statement conflicted with the REFERENCE constraint "AC
T_FK_VAR_EXE". The conflict occurred in database "xxx", table "dbo.ACT_RU_VARIABLE", column 'EXECUTION_ID_'.
-
-
- The error may involve org.activiti.engine.impl.persistence.entity.ExecutionEntity.deleteExecution-Inline
- The error occurred while setting parameters
- Cause: java.sql.SQLException: The DELETE statement conflicted with the REFERENCE constraint "ACT_FK_VAR_EXE". The conflic
t occurred in database "xxx", table "dbo.ACT_RU_VARIABLE", column 'EXECUTION_ID_'.
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:120)
at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSqlSession.java:131)
at org.activiti.engine.impl.db.DbSqlSession$DeleteById.execute(DbSqlSession.java:146)
at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:444)
at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:349)
at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:147)
at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:103)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:49)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
at org.activiti.engine.impl.TaskServiceImpl.complete(TaskServiceImpl.java:144)[/code]
-
-
- CreateTaskListener.java
- 13/Jan/12 3:33 PM
- 0.8 kB
- Marina
-
Hide
- fork_bug.zip
- 13/Jan/12 3:37 PM
- 3.90 MB
- Marina
-
- fork_bug/.classpath 1 kB
- fork_bug/.project 0.4 kB
- fork_bug/libs/activation-1.1.jar 62 kB
- fork_bug/libs/activiti-engine-5.8.jar 1.02 MB
- fork_bug/libs/commons-email-1.2.jar 32 kB
- fork_bug/libs/commons-logging-1.1.1.jar 59 kB
- fork_bug/libs/h2-1.2.132.jar 1.12 MB
- fork_bug/libs/livetribe-jsr223-2.0.6.jar 14 kB
- fork_bug/libs/mail-1.4.1.jar 437 kB
- fork_bug/libs/mybatis-3.0.4.jar 626 kB
- fork_bug/.../spring-asm-3.0.3.RELEASE.jar 52 kB
- fork_bug/.../spring-beans-3.0.3.RELEASE.jar 541 kB
- fork_bug/.../spring-core-3.0.3.RELEASE.jar 357 kB
- fork_bug/process/.../ForkProcess.bpmn20.xml 1 kB
- fork_bug/resources/mem-test.cfg.xml 1 kB
- fork_bug/src/.../CreateTaskListener.java 0.8 kB
- fork_bug/test/.../ForkProcessTest.java 2 kB
-
- ForkProcess.bpmn20_withJoin.xml.by_saeid
- 04/Jan/13 9:36 AM
- 2 kB
- saeid mirzaei
-
- ForkProcess.bpmn20.xml
- 13/Jan/12 3:33 PM
- 1 kB
- Marina
-
- ForkProcessTest.java
- 13/Jan/12 3:33 PM
- 2 kB
- Marina
Activity
Attaching individual files, including task listener class.
Alternatively, attaching eclipse project with the test case in case it makes it easier to setup.
Thanks for looking into it!
I forgot to mention that I'm using PostgreSQL and Activiti 5.9
Here is the full stacktrace:
org.apache.ibatis.exceptions.PersistenceException: ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table "act_ru_execution" violates foreign key constraint "act_fk_var_exe" on table "act_ru_variable" Detail: Key (id_)=(17126) is still referenced from table "act_ru_variable". ### The error may involve org.activiti.engine.impl.persistence.entity.ExecutionEntity.deleteExecution-Inline ### The error occurred while setting parameters ### SQL: delete from ACT_RU_EXECUTION where ID_ = ? ### Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table "act_ru_execution" violates foreign key constraint "act_fk_var_exe" on table "act_ru_variable" Detail: Key (id_)=(17126) is still referenced from table "act_ru_variable".
stack trace:
org.apache.ibatis.exceptions.PersistenceException:
-
-
- Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table "act_ru_execution" violates foreign key constraint "act_fk_var_exe" on table "act_ru_variable"
Detail: Key (id_)=(17126) is still referenced from table "act_ru_variable". - The error may involve org.activiti.engine.impl.persistence.entity.ExecutionEntity.deleteExecution-Inline
- The error occurred while setting parameters
- SQL: delete from ACT_RU_EXECUTION where ID_ = ?
- Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table "act_ru_execution" violates foreign key constraint "act_fk_var_exe" on table "act_ru_variable"
Detail: Key (id_)=(17126) is still referenced from table "act_ru_variable".
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:147)
at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSqlSession.java:158)
at org.activiti.engine.impl.db.DbSqlSession$DeleteById.execute(DbSqlSession.java:146)
at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:483)
at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:371)
at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:157)
at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:109)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:49)
at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
at org.activiti.engine.impl.TaskServiceImpl.complete(TaskServiceImpl.java:144)
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "act_ru_execution" violates foreign key constraint "act_fk_var_exe" on table "act_ru_variable"
Detail: Key (id_)=(17126) is still referenced from table "act_ru_variable".
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:381)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45)
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108)
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:145)
- Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table "act_ru_execution" violates foreign key constraint "act_fk_var_exe" on table "act_ru_variable"
-
I got this one fixed. Or do be correct - it was already fixed.
I was trying to use parallel sequence flow without using parallel gateway, because the user guide states that: "A sequence flow can have a condition defined on it. When a BPMN 2.0 activity is left, the default behavior is to evaluate the conditions on the outgoing sequence flow. When a condition evaluates to true, that outgoing sequence flow is selected. When multiple sequence flow are selected that way, multiple executions will be generated and the process will be continued in a parallel way."
So I presumed that when I define two sequence flows that both evaluate to true then the Activiti will automatically continue in parallel way and I don't have to set parallel gateway.
But that didn't work. When I used parallel gateway (<parallelGateway id="myParallelGateway" />), then everything started to work as expected.
Thank you for your reply. I have two parallel gateways one for the split (fork) and after some tasks it follows the second parallel gateway which makes the join. When i reach the next user task (this is the expected task) i set a variable which is necessary for the next gateway and then i complete the task. After this i get the exception:
org.apache.ibatis.exceptions.PersistenceException:
-
-
- Error updating database. Cause: java.sql.SQLException: ORA-02292: integrity constraint (schema.ACT_FK_VAR_EXE) violated - child record found
-
-
-
- The error may involve org.activiti.engine.impl.persistence.entity.ExecutionEntity.deleteExecution-Inline
- The error occurred while setting parameters
- SQL: delete from ACT_RU_EXECUTION where ID_ = ?
- Cause: java.sql.SQLException: ORA-02292: integrity constraint (schema.ACT_FK_VAR_EXE) violated - child record found
-
I do not know how i can solve this problem.
First of all, I am not sure if the given process is a valid BPMN process. The problem is that a parallel gateway us used without a corresponding a join gateway. The recommended way of join is using a parallel gateway.
by addition of a join gateway, the very same sample works just fine. I have attached BPMN "ForkProcess_withJoin.bpmn20.xml" to show it.
As is mentioned in this document http://www.omg.org/bpmn/Documents/Notations_and_Workflow_Patterns.pdf it seems that, the parallel fork should be followed by a join except when each path concludes in a SEPERATE end event ,According to According to BPMN Method & Style (Bruce Silver, page 29:
<<
Each outgoing path thus represents a parallel (concurrent) thread of process activity. Parallel paths may be joined downstream or may lead to separate end events. Each parallel path must reach an end event in order for the process or subprocess complete.
>>
Again I changed the given case to have two distinct end events, one for each parallel path. The problem still exist. I don't know if it is worth fixing or not
First of all, In the sample there is a parallell fork gateway without corresponding join gateway. As a quick resolution, the problem will vanish if a join gateway is used. I have attached a modified version with a join gateway which works fine. Its name is "ForkProcess.bpmn20.xml.fixed".
This is the recommended usage of parallel gateway.
but anyway, it seems the given process is a valid
by the way, I just used this thread http://forums.activiti.org/en/viewtopic.php?f=6&t=3176 for the reference to "BPMN Method & Style" book
Fixed in pull request https://github.com/Activiti/Activiti/pull/22. Waiting to be merged
Please attach an example process and a testcase which allows us to reproduce the issue.
Thanks.