Details
-
Task
-
Resolution: Done
-
Major
-
7.11.1.GA
-
False
-
None
-
False
-
CR1
-
+
-
---
-
---
Description
Scenario:
RHPAM 7.11.1 on SpringBoot.
org.kie.api.persistence.pessimistic=true
During the retry of the parent process, the following error happens:
2022-08-19 12:16:54.143 [Camel (camel-1) thread #0 - JmsConsumer[IT.POSTE.BPM.SCARTI.SWITCHIN.RETRY]] WARN o.d.persistence.PersistableRunner - Could not commit session org.jbpm.workflow.instance.WorkflowRuntimeException: [switchin:34,152 - Aggiorna CRM - Esito Check Hub:27] -- id to load is required for loading at org.jbpm.workflow.instance.node.WorkItemNodeInstance.processWorkItemHandler(WorkItemNodeInstance.java:173) at org.jbpm.workflow.instance.node.WorkItemNodeInstance.exceptionHandlingCompleted(WorkItemNodeInstance.java:566) at org.jbpm.workflow.instance.node.WorkItemNodeInstance.signalEvent(WorkItemNodeInstance.java:357) at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.signalEvent(WorkflowProcessInstanceImpl.java:666) at org.jbpm.process.instance.event.DefaultSignalManager.internalSignalEvent(DefaultSignalManager.java:88) at org.jbpm.process.instance.event.DefaultSignalManager.signalEvent(DefaultSignalManager.java:80) at org.jbpm.persistence.processinstance.JPASignalManager.signalEvent(JPASignalManager.java:82) at org.jbpm.process.instance.ProcessRuntimeImpl.signalEvent(ProcessRuntimeImpl.java:584) at org.drools.core.impl.StatefulKnowledgeSessionImpl.signalEvent(StatefulKnowledgeSessionImpl.java:573) at org.drools.core.command.runtime.process.SignalEventCommand.execute(SignalEventCommand.java:114) at org.drools.core.command.runtime.process.SignalEventCommand.execute(SignalEventCommand.java:37) ... Caused by: java.lang.IllegalArgumentException: id to load is required for loading at org.hibernate.event.spi.LoadEvent.<init>(LoadEvent.java:96) at org.hibernate.event.spi.LoadEvent.<init>(LoadEvent.java:60) ... at org.drools.persistence.jpa.JpaPersistenceContext.merge(JpaPersistenceContext.java:152) at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.retryWorkItemWithParams(JPAWorkItemManager.java:91) at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.retryWorkItem(JPAWorkItemManager.java:281) at org.jbpm.workflow.instance.node.WorkItemNodeInstance.lambda$exceptionHandlingCompleted$2(WorkItemNodeInstance.java:566) at org.jbpm.workflow.instance.node.WorkItemNodeInstance.processWorkItemHandler(WorkItemNodeInstance.java:158) ... 98 common frames omitted
If they remove org.kie.api.persistence.pessimistic=true, the above error does not happen.
The customer performed some debugging on the JBPM/Drools library classes and they found out that class: org.drools.persistence.jpa.JpaPersistenceContext [1] and method merge is only performed when pessimistic lock is enabled.
In this class, it fails in the line 152 [2]:
WorkItemInfo dbWorkItemInfo = em.find(WorkItemInfo.class, workItem.getId(), lockMode);
In this case, workItem.getId() is null and because of that, the above error is thrown. Method merge is invoked by the class org.drools.persistence.jpa.processinstance.JPAWorkItemManager [3] in the method retryWorkItemWithParams:
public void retryWorkItemWithParams(long workItemId, Map < String, Object > map) { Environment env = this.kruntime.getEnvironment(); WorkItem workItem = getWorkItem(workItemId); if (workItem != null) { workItem.setParameters(map); WorkItemInfo workItemInfo = new WorkItemInfo(workItem, env); PersistenceContext context = getPersistenceContext(); context.merge(workItemInfo); retryWorkItem(workItem); } }
In this method, the problem happens in the following line:
WorkItemInfo workItemInfo = new WorkItemInfo( workItem, env );
as this constructor of WorkItemInfo [4] does not set the value of id:
public WorkItemInfo(WorkItem workItem, Environment env) { this.workItem = workItem; this.name = workItem.getName(); this.creationDate = new Date(); this.processInstanceId = workItem.getProcessInstanceId(); this.env = env; }
FIX PROPOSED:
To solve this, it is possible to override the JPAWorkItemManager class in the following way:
public void retryWorkItemWithParams(long workItemId, Map < String, Object > map) { Environment env = this.kruntime.getEnvironment(); WorkItem workItem = getWorkItem(workItemId); if (workItem != null) { workItem.setParameters(map); WorkItemInfo workItemInfo = new WorkItemInfo(workItem, env); PersistenceContext context = getPersistenceContext(); if (workItemInfo.getId() == null) { workItemInfo.setId(new Long(workItemId)); } context.merge(workItemInfo); retryWorkItem(workItem); } }
This fix solves the issue on the customer environment. Please could you validate if this fix is valid / can be added in the product ?
References:
[1]
[2]
[3]
[4]
Attachments
Issue Links
- is cloned by
-
JBPM-10117 [03296177] Could not commit session during retry of the parent process
- Resolved