AnsweredAssumed Answered

'Integrity constraint violation' between CallActivities

Question asked by gokceng1 on Dec 17, 2012
Latest reply on Apr 22, 2014 by jbarrez
Hi,
I have some complex process definition consisting of 12 call activities. You can find main process here.
The error stack is here:
5924 [main] ERROR org.activiti.engine.impl.interceptor.CommandContext  - Error while closing command context
org.apache.ibatis.exceptions.PersistenceException:
### Error updating database.  Cause: org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "ACT_FK_EVENT_EXEC: PUBLIC.ACT_RU_EVENT_SUBSCR FOREIGN KEY(EXECUTION_ID_) REFERENCES PUBL
IC.ACT_RU_EXECUTION(ID_) ('307')"; SQL statement:
delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ? [23503-170]
   at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
   at org.h2.message.DbException.get(DbException.java:169)
   at org.h2.message.DbException.get(DbException.java:146)
   at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:414)
   at org.h2.constraint.ConstraintReferential.checkRowRefTable(ConstraintReferential.java:431)
   at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:307)
   at org.h2.table.Table.fireConstraints(Table.java:870)
   at org.h2.table.Table.fireAfterRow(Table.java:887)
   at org.h2.command.dml.Delete.update(Delete.java:99)
   at org.h2.command.CommandContainer.update(CommandContainer.java:75)
   at org.h2.command.Command.executeUpdate(Command.java:230)
   at org.h2.server.TcpServerThread.process(TcpServerThread.java:333)
   at org.h2.server.TcpServerThread.run(TcpServerThread.java:149)
   at java.lang.Thread.run(Thread.java:722)

### 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_ = ? and REV_ = ?
### Cause: org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "ACT_FK_EVENT_EXEC: PUBLIC.ACT_RU_EVENT_SUBSCR FOREIGN KEY(EXECUTION_ID_) REFERENCES PUBLIC.ACT_RU_EXECUTION(ID_) (
'307')"; SQL statement:
delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ? [23503-170]
   at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
   at org.h2.message.DbException.get(DbException.java:169)
   at org.h2.message.DbException.get(DbException.java:146)
   at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:414)
   at org.h2.constraint.ConstraintReferential.checkRowRefTable(ConstraintReferential.java:431)
   at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:307)
   at org.h2.table.Table.fireConstraints(Table.java:870)
   at org.h2.table.Table.fireAfterRow(Table.java:887)
   at org.h2.command.dml.Delete.update(Delete.java:99)
   at org.h2.command.CommandContainer.update(CommandContainer.java:75)
   at org.h2.command.Command.executeUpdate(Command.java:230)
   at org.h2.server.TcpServerThread.process(TcpServerThread.java:333)
   at org.h2.server.TcpServerThread.run(TcpServerThread.java:149)
   at java.lang.Thread.run(Thread.java:722)

   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$DeletePersistentObjectOperation.execute(DbSqlSession.java:236)
   at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:667)
   at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:461)
   at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:167)
   at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:114)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:69)
   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:32)
   at org.activiti.engine.impl.RuntimeServiceImpl.signal(RuntimeServiceImpl.java:174)
   at org.activiti.designer.test.ProcessTestPstnCopperActivationProcess.shouldFailRetryAndContinue(ProcessTestPstnCopperActivationProcess.java:116)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:601)
   at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
   at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
   at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
   at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
   at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
   at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
   at org.junit.rules.TestWatchman$1.evaluate(TestWatchman.java:48)
   at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
   at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
   at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
   at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
   at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
   at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
   at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
   at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
   at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
   at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
   at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
   at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
   at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "ACT_FK_EVENT_EXEC: PUBLIC.ACT_RU_EVENT_SUBSCR FOREIGN KEY(EXECUTION_ID_) REFERENCES PUBLIC.ACT_RU_EXECUTION(ID_) (
'307')"; SQL statement:
delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ? [23503-170]
   at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
   at org.h2.message.DbException.get(DbException.java:169)
   at org.h2.message.DbException.get(DbException.java:146)
   at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:414)
   at org.h2.constraint.ConstraintReferential.checkRowRefTable(ConstraintReferential.java:431)
   at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:307)
   at org.h2.table.Table.fireConstraints(Table.java:870)
   at org.h2.table.Table.fireAfterRow(Table.java:887)
   at org.h2.command.dml.Delete.update(Delete.java:99)
   at org.h2.command.CommandContainer.update(CommandContainer.java:75)
   at org.h2.command.Command.executeUpdate(Command.java:230)
   at org.h2.server.TcpServerThread.process(TcpServerThread.java:333)
   at org.h2.server.TcpServerThread.run(TcpServerThread.java:149)
   at java.lang.Thread.run(Thread.java:722)

   at org.h2.engine.SessionRemote.done(SessionRemote.java:505)
   at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:190)
   at org.h2.jdbc.JdbcPreparedStatement.execute(JdbcPreparedStatement.java:179)
   at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:601)
   at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:58)
   at $Proxy14.execute(Unknown Source)
   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)
   … 43 more
6018 [main] ERROR org.activiti.engine.impl.interceptor.CommandContext  - Error while closing command context
org.apache.ibatis.exceptions.PersistenceException:
### Error updating database.  Cause: org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "ACT_FK_EVENT_EXEC: PUBLIC.ACT_RU_EVENT_SUBSCR FOREIGN KEY(EXECUTION_ID_) REFERENCES PUBL
IC.ACT_RU_EXECUTION(ID_) ('307')"; SQL statement:
delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ? [23503-170]
   at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
   at org.h2.message.DbException.get(DbException.java:169)
   at org.h2.message.DbException.get(DbException.java:146)
   at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:414)
   at org.h2.constraint.ConstraintReferential.checkRowRefTable(ConstraintReferential.java:431)
   at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:307)
   at org.h2.table.Table.fireConstraints(Table.java:870)
   at org.h2.table.Table.fireAfterRow(Table.java:887)
   at org.h2.command.dml.Delete.update(Delete.java:99)
   at org.h2.command.CommandContainer.update(CommandContainer.java:75)
   at org.h2.command.Command.executeUpdate(Command.java:230)
   at org.h2.server.TcpServerThread.process(TcpServerThread.java:333)
   at org.h2.server.TcpServerThread.run(TcpServerThread.java:149)
   at java.lang.Thread.run(Thread.java:722)

### 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_ = ? and REV_ = ?
### Cause: org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "ACT_FK_EVENT_EXEC: PUBLIC.ACT_RU_EVENT_SUBSCR FOREIGN KEY(EXECUTION_ID_) REFERENCES PUBLIC.ACT_RU_EXECUTION(ID_) (
'307')"; SQL statement:
delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ? [23503-170]
   at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
   at org.h2.message.DbException.get(DbException.java:169)
   at org.h2.message.DbException.get(DbException.java:146)
   at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:414)
   at org.h2.constraint.ConstraintReferential.checkRowRefTable(ConstraintReferential.java:431)
   at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:307)
   at org.h2.table.Table.fireConstraints(Table.java:870)
   at org.h2.table.Table.fireAfterRow(Table.java:887)
   at org.h2.command.dml.Delete.update(Delete.java:99)
   at org.h2.command.CommandContainer.update(CommandContainer.java:75)
   at org.h2.command.Command.executeUpdate(Command.java:230)
   at org.h2.server.TcpServerThread.process(TcpServerThread.java:333)
   at org.h2.server.TcpServerThread.run(TcpServerThread.java:149)
   at java.lang.Thread.run(Thread.java:722)

   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$DeletePersistentObjectOperation.execute(DbSqlSession.java:236)
   at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:667)
   at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:461)
   at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:167)
   at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:114)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:69)
   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:32)
   at org.activiti.engine.impl.RepositoryServiceImpl.deleteDeployment(RepositoryServiceImpl.java:80)
   at org.activiti.engine.impl.test.TestHelper.annotationDeploymentTearDown(TestHelper.java:107)
   at org.activiti.engine.test.ActivitiRule.finished(ActivitiRule.java:119)
   at org.junit.rules.TestWatchman$1.evaluate(TestWatchman.java:54)
   at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
   at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
   at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
   at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
   at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
   at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
   at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
   at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
   at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
   at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
   at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
   at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
   at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "ACT_FK_EVENT_EXEC: PUBLIC.ACT_RU_EVENT_SUBSCR FOREIGN KEY(EXECUTION_ID_) REFERENCES PUBLIC.ACT_RU_EXECUTION(ID_) (
'307')"; SQL statement:
delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ? [23503-170]
   at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
   at org.h2.message.DbException.get(DbException.java:169)
   at org.h2.message.DbException.get(DbException.java:146)
   at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:414)
   at org.h2.constraint.ConstraintReferential.checkRowRefTable(ConstraintReferential.java:431)
   at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:307)
   at org.h2.table.Table.fireConstraints(Table.java:870)
   at org.h2.table.Table.fireAfterRow(Table.java:887)
   at org.h2.command.dml.Delete.update(Delete.java:99)
   at org.h2.command.CommandContainer.update(CommandContainer.java:75)
   at org.h2.command.Command.executeUpdate(Command.java:230)
   at org.h2.server.TcpServerThread.process(TcpServerThread.java:333)
   at org.h2.server.TcpServerThread.run(TcpServerThread.java:149)
   at java.lang.Thread.run(Thread.java:722)

   at org.h2.engine.SessionRemote.done(SessionRemote.java:505)
   at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:190)
   at org.h2.jdbc.JdbcPreparedStatement.execute(JdbcPreparedStatement.java:179)
   at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:601)
   at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:58)
   at $Proxy14.execute(Unknown Source)
   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)
   … 34 more
6027 [Thread-3] INFO  org.springframework.context.support.GenericApplicationContext  - Closing org.springframework.context.support.GenericApplicationContext@14b2819: startup date [Fri Dec 14 17:55:37
EET 2012]; root of context hierarchy

I can prepare a test project if you demand.
Thanks in advance.

UPDATE:
Let me explain some details before showing my findings.
I have 3 level processes: 1 main process which is shown in the image. Forget about the compensation and error handlers. I have 2 call activities named Local Loop Process and MDF Connection Process. Both call similar processes with different parameters(This is level 2). I pass a bean and a method name but I don't think it is important. In level 3, I just have a generic process trying to execute bean's method and handles error(s).

Local Loop Process -> Middle Tier1 Process -> Generic Process
MDF Connection Process -> Middle Tier2 Process -> Generic Process

In generic process(image here), as you see I have a 'Wait on IT Fault State' script task. In original erroneous process definition it was receive or user task. I changed it from receive task to user task and problem still exists. I changed it to a script task and problem is gone. The problem is it should be a wait state waiting for user/external system interaction.

I don't have a clue about this situation. If it is a script task then no error. If it is a wait state(receive/user task), after 3rd level's and 2nd level's completion, even after 1st level's completion I get the error above.

Outcomes