# Issue when starting a cmmn instance

**URL:** <https://forum.flowable.org/t/issue-when-starting-a-cmmn-instance/5115>\
**Category:** Flowable Engine\
**Created:** [December 19, 2019, 1:41pm UTC](https://forum.flowable.org/t/issue-when-starting-a-cmmn-instance/5115 "2019-12-19T13:41:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ddpardo](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@ddpardo](https://forum.flowable.org/u/ddpardo)\
**Post date:** [December 19, 2019, 1:41pm UTC](https://forum.flowable.org/t/issue-when-starting-a-cmmn-instance/5115/1 "2019-12-19T13:41:10Z")

</div>

Hi all,

When starting a case definition instance i am receiving the following error:

> ```
> 2019-12-19 12:19:18,530 ERROR [user=,ip=][org.springframework.boot.web.servlet.support.ErrorPageFilter] (default task-1) Forwarding to error page from request [/cmmn/instances/start] due to exception [
> 
> ```
> 
> ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: insert or update on table “act\_ru\_identitylink” violates foreign key constraint “act\_fk\_tskass\_task”
> 
> Detail: Key (task\_id\_)=(65df7578-2251-11ea-990a-0242ac140009) is not present in table “act\_ru\_task”.
> 
> ### The error may exist in org/flowable/identitylink/service/db/mapping/entity/IdentityLink.xml
> 
> ### The error may involve org.flowable.identitylink.service.impl.persistence.entity.IdentityLinkEntityImpl.insertIdentityLink-Inline
> 
> ### The error occurred while setting parameters
> 
> ### SQL: insert into ACT\_RU\_IDENTITYLINK (ID\_, REV\_, TYPE\_, USER\_ID\_, GROUP\_ID\_, TASK\_ID\_, PROC\_INST\_ID\_, PROC\_DEF\_ID\_, SCOPE\_ID\_, SCOPE\_TYPE\_, SCOPE\_DEFINITION\_ID\_) values (?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?)
> 
> ### Cause: org.postgresql.util.PSQLException: ERROR: insert or update on table “act\_ru\_identitylink” violates foreign key constraint “act\_fk\_tskass\_task”
> 
> Detail: Key (task\_id\_)=(65df7578-2251-11ea-990a-0242ac140009) is not present in table “act\_ru\_task”.]: org.apache.ibatis.exceptions.PersistenceException:
> 
> ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: insert or update on table “act\_ru\_identitylink” violates foreign key constraint “act\_fk\_tskass\_task”
> 
> Detail: Key (task\_id\_)=(65df7578-2251-11ea-990a-0242ac140009) is not present in table “act\_ru\_task”.
> 
> ### The error may exist in org/flowable/identitylink/service/db/mapping/entity/IdentityLink.xml
> 
> ### The error may involve org.flowable.identitylink.service.impl.persistence.entity.IdentityLinkEntityImpl.insertIdentityLink-Inline
> 
> ### The error occurred while setting parameters
> 
> ### SQL: insert into ACT\_RU\_IDENTITYLINK (ID\_, REV\_, TYPE\_, USER\_ID\_, GROUP\_ID\_, TASK\_ID\_, PROC\_INST\_ID\_, PROC\_DEF\_ID\_, SCOPE\_ID\_, SCOPE\_TYPE\_, SCOPE\_DEFINITION\_ID\_) values (?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?)
> 
> ### Cause: org.postgresql.util.PSQLException: ERROR: insert or update on table “act\_ru\_identitylink” violates foreign key constraint “act\_fk\_tskass\_task”
> 
> Detail: Key (task\_id\_)=(65df7578-2251-11ea-990a-0242ac140009) is not present in table “act\_ru\_task”.

The cmmn model is a single human task with the candidate groups set to admin. If I remove the candidate groups attribute the instance starts. Any pointers available why this constraint is met?

Additional background:

- Database is freshly created or on an existing database.
- Used both the spring boot starter and the manual spring setup
- Tested on Postgres versions 9, 10
- Endpoint is a simple spring controller calling the caseinstancebuilder start method.
- case definition model was designed trough using the flowable-modeler.

Let me know If additional info is needed.

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [December 20, 2019, 2:23pm UTC](https://forum.flowable.org/t/issue-when-starting-a-cmmn-instance/5115/2 "2019-12-20T14:23:22Z")

</div>

I tried to reproduce here: [https://github.com/flowable/flowable-engine/commit/1e3ae15324b266a7f3f8a2a645faf220b273e3ba](https://github.com/flowable/flowable-engine/commit/1e3ae15324b266a7f3f8a2a645faf220b273e3ba), but that unit test works. Can you share the cmmn xml?

---

<div class="post-metadata">

**Author:** ![ddpardo](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@ddpardo](https://forum.flowable.org/u/ddpardo)\
**Post date:** [December 21, 2019, 11:39am UTC](https://forum.flowable.org/t/issue-when-starting-a-cmmn-instance/5115/3 "2019-12-21T11:39:08Z")

</div>

Hi joram,

> <https://gist.github.com/ddpardo/e47d841ce4e73b60ef35be036b4bf6ca>

---

<div class="post-metadata">

**Author:** ![ddpardo](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@ddpardo](https://forum.flowable.org/u/ddpardo)\
**Post date:** [December 31, 2019, 2:43pm UTC](https://forum.flowable.org/t/issue-when-starting-a-cmmn-instance/5115/4 "2019-12-31T14:43:02Z")

</div>

Hi Joram,

I changed the project dependencies to spring boot starters and it now successful starts the instance. The only noticeable differences is that the priority of the engines in comparison to when manually creating the beans.

> 14:26:30,039 INFO [org.flowable.spring.boot.ProcessEngineAutoConfiguration$$EnhancerBySpringCGLIB$$f7e5801d] (ServerService Thread Pool – 113) No deployment resources were found for autodeployment  
> 14:26:30,122 INFO [org.flowable.spring.SpringProcessEngineConfiguration] (ServerService Thread Pool – 113) Found 2 Engine Configurators in total:  
> 14:26:30,122 INFO [org.flowable.spring.SpringProcessEngineConfiguration] (ServerService Thread Pool – 113) class org.flowable.idm.engine.configurator.IdmEngineConfigurator (priority:100000)  
> 14:26:30,123 INFO [org.flowable.spring.SpringProcessEngineConfiguration] (ServerService Thread Pool – 113) class org.flowable.cmmn.spring.configurator.SpringCmmnEngineConfigurator (priority:500000)  
> 14:26:30,123 INFO [org.flowable.spring.SpringProcessEngineConfiguration] (ServerService Thread Pool – 113) Executing beforeInit() of class org.flowable.idm.engine.configurator.IdmEngineConfigurator (priority:100000)  
> 14:26:30,126 INFO [org.flowable.spring.SpringProcessEngineConfiguration] (ServerService Thread Pool – 113) Executing beforeInit() of class org.flowable.cmmn.spring.configurator.SpringCmmnEngineConfigurator (priority:500000)  
> 14:26:31,510 INFO [org.flowable.spring.SpringProcessEngineConfiguration] (ServerService Thread Pool – 113) Found compatibility handler instance : class org.activiti.compatibility.spring.DefaultFlowable5SpringCompatibilityHandler  
> 14:26:31,563 INFO [org.flowable.spring.SpringProcessEngineConfiguration] (ServerService Thread Pool – 113) Executing configure() of class org.flowable.idm.engine.configurator.IdmEngineConfigurator (priority:100000)  
> 14:26:31,587 INFO [org.flowable.spring.SpringProcessEngineConfiguration] (ServerService Thread Pool – 113) Executing configure() of class org.flowable.cmmn.spring.configurator.SpringCmmnEngineConfigurator (priority:500000)  
> 14:26:31,657 INFO [org.flowable.job.service.impl.asyncexecutor.AbstractAsyncExecutor] (ServerService Thread Pool – 113) Starting up the async job executor [org.flowable.spring.job.service.SpringAsyncExecutor].  
> 14:26:31,658 INFO [org.flowable.job.service.impl.asyncexecutor.AcquireAsyncJobsDueRunnable] (Thread-153) starting to acquire async jobs due  
> 14:26:31,659 INFO [org.flowable.job.service.impl.asyncexecutor.AcquireTimerJobsRunnable] (Thread-154) starting to acquire async jobs due  
> 14:26:31,659 INFO [org.flowable.cmmn.engine.impl.CmmnEngineImpl] (ServerService Thread Pool – 113) CmmnEngine default created  
> 14:26:31,664 INFO [org.flowable.job.service.impl.asyncexecutor.ResetExpiredJobsRunnable] (Thread-155) starting to reset expired jobs for engine cmmn  
> 14:26:31,673 INFO [org.flowable.engine.impl.ProcessEngineImpl] (ServerService Thread Pool – 113) ProcessEngine default created  
> 14:26:31,682 INFO [org.flowable.job.service.impl.asyncexecutor.AbstractAsyncExecutor] (ServerService Thread Pool – 113) Starting up the async job executor [org.flowable.spring.job.service.SpringAsyncExecutor].  
> 14:26:31,684 INFO [org.flowable.job.service.impl.asyncexecutor.AcquireAsyncJobsDueRunnable] (Thread-156) starting to acquire async jobs due

Also another question:

- Is it still possible to use a JTA datasource (ex. managed by wildfly) in combination with schemaupdate set to true / false? The current implementation commits the transaction resulting in “java.sql.SQLException: IJ031019: You cannot commit during a managed transaction”.

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [January 6, 2020, 9:32pm UTC](https://forum.flowable.org/t/issue-when-starting-a-cmmn-instance/5115/5 "2020-01-06T21:32:47Z")

</div>

> [@ddpardo](#):
>
> The only noticeable differences is that the priority of the engines in comparison to when manually creating the beans.

Do you still have the way you had set them up before? The cmmn engine should indeed go after the bpmn engine (and if the app engine is used, they both should go after that one), so maybe that was the problem.

> [@ddpardo](#):
>
> Is it still possible to use a JTA datasource (ex. managed by wildfly) in combination with schemaupdate set to true / false? The current implementation commits the transaction resulting in “java.sql.SQLException: IJ031019: You cannot commit during a managed transaction”.

Which database are you using? Do you have a stacktrace? We’re not committing during schema creation (I think), so not sure what’s going on here.

---

<div class="post-metadata">

**Author:** ![ddpardo](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@ddpardo](https://forum.flowable.org/u/ddpardo)\
**Post date:** [January 7, 2020, 5:39pm UTC](https://forum.flowable.org/t/issue-when-starting-a-cmmn-instance/5115/6 "2020-01-07T17:39:55Z")

</div>

Hi joram,

You can find a slim downed version here: [https://github.com/ddpardo/flowable-engine-order-prototype](https://github.com/ddpardo/flowable-engine-order-prototype)  
It uses spring boot to start datasource & tomcat.The engines are manually created. Additional instructions in the readme how to create the error.

For the JTA issue, the error is caused by the commit call, when deploying the engine on a wildfly where the datasource is managed by wildfly itself. I have only tested with postgresql:

> <https://github.com/flowable/flowable-engine/blob/master/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/db/LiquibaseBasedSchemaManager.java#L139-L146>

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [January 17, 2020, 10:59pm UTC](https://forum.flowable.org/t/issue-when-starting-a-cmmn-instance/5115/7 "2020-01-17T22:59:37Z")

</div>

Thanks for the excellent example app, this made testing it a breeze!  
I did encounter the same problem. However, just for testing I upgraded to the 6.5.0-SNAPSHOT (latest build done from master) and the problem is gone. Most likely it has been fixed on master.  
Can you try building the latest version (clone the repo and then do `mvn -Pdistro clean install -DskipTests`) and giving it a go to double check?
