drools-persistence-jpa - ClassCastException on ForEachNodeInstance
------------------------------------------------------------------
Key: JBRULES-2304
URL:
https://jira.jboss.org/jira/browse/JBRULES-2304
Project: Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: All
Affects Versions: 5.1.0.M1
Reporter: gah doh
Assignee: Mark Proctor
Testing out JPAVariablePersister. It appears the session, processes, and variables are
persisted. However, when I try to load the session again, and reopen the process as
follows, I get a ClassCastException.
StatefulKnowledgeSession session = JPAKnowledgeService.loadStatefulKnowledgeSession(
1, knowledgeBase, null, env );
ProcessInstance processClm = session.getProcessInstance(1);
The second line (ClaimsDemoJpaTest.java:182) is the source of the stack trace below. The
error makes sense, as:
ForEachNodeInstance extends CompositeNodeInstance
CompositeContextNodeInstance extends CompositeNodeInstance
So they clearly cannot be cast to each other, but I'm not of how to troubleshoot this
beyond that. The line of code throwing the error clearly expects to be able to cast the
nodeInstance.
restoreVariable(variableInfo, parentIds, variableName, (CompositeContextNodeInstance)
nodeInstance);
Here is the stack:
java.lang.ClassCastException: org.drools.workflow.instance.node.ForEachNodeInstance cannot
be cast to org.drools.workflow.instance.node.CompositeContextNodeInstance
at
org.drools.persistence.processinstance.ProcessInstanceInfo.restoreVariable(ProcessInstanceInfo.java:198)
at
org.drools.persistence.processinstance.ProcessInstanceInfo.restoreVariables(ProcessInstanceInfo.java:166)
at
org.drools.persistence.processinstance.ProcessInstanceInfo.getProcessInstance(ProcessInstanceInfo.java:144)
at
org.drools.persistence.processinstance.JPAProcessInstanceManager.getProcessInstance(JPAProcessInstanceManager.java:62)
at
org.drools.common.AbstractWorkingMemory.getProcessInstance(AbstractWorkingMemory.java:1720)
at
org.drools.impl.StatefulKnowledgeSessionImpl.getProcessInstance(StatefulKnowledgeSessionImpl.java:261)
at
org.drools.command.runtime.process.GetProcessInstanceCommand.execute(GetProcessInstanceCommand.java:29)
at
org.drools.command.runtime.process.GetProcessInstanceCommand.execute(GetProcessInstanceCommand.java:12)
at
org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:254)
at
org.drools.command.impl.CommandBasedStatefulKnowledgeSession.getProcessInstance(CommandBasedStatefulKnowledgeSession.java:92)
at
com.csatp.svc.rulesmgr.claim.ClaimsDemoJpaTest.validateDocumentWorkflow2(ClaimsDemoJpaTest.java:182)
Obviously this is a flow with a ForEach node. The ForEach calls a subflow for each item in
the List claim.roles, in my test case, there are 2 subflows.
I don't know if it helps, but here is the forEach node from the flow:
<forEach id="2" name="ForEach" x="423" y="62"
width="200" height="150" variableName="role"
collectionExpression="claim.roles" >
<nodes>
<subProcess id="1" name="Document Workflow" x="36"
y="40" width="132" height="48"
processId="DocumentWorkflow2" >
<mapping type="in" from="role" to="role" />
</subProcess>
</nodes>
<connections>
</connections>
<in-ports>
<in-port type="DROOLS_DEFAULT" nodeId="1"
nodeInType="DROOLS_DEFAULT" />
</in-ports>
<out-ports>
<out-port type="DROOLS_DEFAULT" nodeId="1"
nodeOutType="DROOLS_DEFAULT" />
</out-ports>
</forEach>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira