Details
-
Type:
Service Pack Request
-
Status: Open (View Workflow)
-
Resolution: Unresolved
-
Affects Version/s: Alfresco Process Services 1.9.0.3
-
Fix Version/s: Alfresco Process Services .N
-
Component/s: APS Engine
-
Labels:None
-
Bug Priority:
-
ACT Numbers:
00976451, 00974304
Description
Summary
While using the userService or groupServiceImpl in an expression to assign parallel multi-instance user tasks to all members of a specific group, an infinite recursion StackOverFlow error is thrown similar to the following:
06:59:50 [http-nio-8443-exec-3] WARN com.activiti.service.reporting.eventhandler.AbstractActivitiEventHandler --MDC-- --MDC-- - Could not serialize event data. Data will not be written to the database com.fasterxml.jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError) (through reference chain: org.hibernate.collection.internal.PersistentSet[0]->com.activiti.domain.idm.User["groups"]->org.hibernate.collection.internal.PersistentBag[0]->com.activiti.domain.idm.Group["users"]-> org.hibernate.collection.internal.PersistentSet[0]->com.activiti.domain.idm.User["groups"]->org.hibernate.collection.internal.PersistentBag[0]->com.activiti.domain.idm.Group["users"]-> org.hibernate.collection.internal.PersistentSet[0]->com.activiti.domain.idm.User["groups"]->org.hibernate.collection.internal.PersistentBag[0]->com.activiti.domain.idm.Group["users"]-> org.hibernate.collection.internal.PersistentSet[0]->com.activiti.domain.idm.User["groups"]->org.hibernate.collection.internal.PersistentBag[0]->com.activiti.domain.idm.Group["users"]-> org.hibernate.collection.internal.PersistentSet[0]->com.activiti.domain.idm.User["groups"]->org.hibernate.collection.internal.PersistentBag[0]->com.activiti.domain.idm.Group["users"]-> org.hibernate.collection.internal.PersistentSet[0]->com.activiti.domain.idm.User["groups"]->org.hibernate.collection.internal.PersistentBag[0]->com.activiti.domain.idm.Group["users"]-> org.hibernate.collection.internal.PersistentSet[0]->com.activiti.domain.idm.User["groups"]->org.hibernate.collection.internal.PersistentBag[0]->com.activiti.domain.idm.Group["users"]-> org.hibernate.collection.internal.PersistentSet[0]->com.activiti.domain.idm.User["groups"]->org.hibernate.collection.internal.PersistentBag[0]->com.activiti.domain.idm.Group["users"]-> ... at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:734) at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:155) at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:145) at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.java:107) ...
Steps to reproduce
1. Make sure you have expression language and bean whitelisting disabled
2. Login to activiti-app as admin
3. Via Identity Management -> Users create some users, e.g. userA, userB and userC
4. Via Identity Management -> Organization create a group "test" and add the users you created in previous step as group members
5. Via App Designer create a new process: start event->user task->end event
6. Define the properties for the user task as followed:
Multi-instance type: Parallel
Collection (Multi-instance): ${groupServiceImpl.getGroupByNameAndTenantId("test", 1).get(0).getUsers()}
Element variable (Multi-instance): user
Assignee:${user.getId()}
NOTE: Above configuration means, that APS should create a new parallel user task, which is assigned to each member of the "test" group.
7. Save process and create and publish an app containing the process
8. From the published app on the landing page, start a new process
9. Inspect the logs
Expected behaviour
Process starts and there are as many user tasks created as there are members in the group "test". Every group member has one task assigned. There are no errors in the APS logs.
Current behaviour
Process starts and there are as many user tasks created as there are members in the group "test". Every group member has one task assigned. The APS logs is full of errors similar to:
06:59:50 [http-nio-8443-exec-3] WARN com.activiti.service.reporting.eventhandler.AbstractActivitiEventHandler --MDC-- --MDC-- - Could not serialize event data. Data will not be written to the database com.fasterxml.jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError) ...
Customer also complains that caused by this infinite recursion, in their case it takes up to 18 minutes for all parallel tasks to be created.
Supporting evidence
- Reproduced with current latest APS 1.9.03 release
- FInd attached an app "multiinstance.zip" that can be used for reproduction after group "test" and members got created
- Instead of just using groupServiceImpl I also tried the following Collection expression
${userService.findUsersForGroup(groupServiceImpl.getGroupByNameAndTenantId("test", 1).get(0).getId(), null, 0, 1000)}
using the userService but ended up with the same infinite recursion issue.
- A general similar issue is described here:
https://stackoverflow.com/questions/3325387/infinite-recursion-with-jackson-json-and-hibernate-jpa-issue - Would solution be to use smth like
https://www.baeldung.com/jackson-bidirectional-relationships-and-infinite-recursion
on user and group entities?