Yes, I think I face that before. The problem is that you need to define the variables in the process definition with the correct type.<br>Can you try with that and get back with that?<br><br><br><div class="gmail_quote">On Mon, Oct 19, 2009 at 12:52 PM, Bill Tarr <span dir="ltr">&lt;<a href="mailto:javatestcase@yahoo.com">javatestcase@yahoo.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">This seems more like a bug, I thought I&#39;d post it here, but point me to the JIRA if I need to enter an issue.<br>

<br>
Still 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.<br>
<br>
    StatefulKnowledgeSession session = JPAKnowledgeService.loadStatefulKnowledgeSession( 1, knowledgeBase, null, env );<br>
    ProcessInstance processClm = session.getProcessInstance(1);<br>
<br>
The second line (ClaimsDemoJpaTest.java:182) is the source of the stack trace below.  The error makes sense, as:<br>
<br>
  ForEachNodeInstance extends CompositeNodeInstance<br>
  CompositeContextNodeInstance extends CompositeNodeInstance<br>
<br>
So they clearly cannot be cast to each other, but I&#39;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.<br>
<br>
     restoreVariable(variableInfo, parentIds, variableName, (CompositeContextNodeInstance) nodeInstance);<br>
<br>
Here is the stack:<br>
<br>
java.lang.ClassCastException: org.drools.workflow.instance.node.ForEachNodeInstance cannot be cast to org.drools.workflow.instance.node.CompositeContextNodeInstance<br>
 at org.drools.persistence.processinstance.ProcessInstanceInfo.restoreVariable(ProcessInstanceInfo.java:198)<br>
 at org.drools.persistence.processinstance.ProcessInstanceInfo.restoreVariables(ProcessInstanceInfo.java:166)<br>
 at org.drools.persistence.processinstance.ProcessInstanceInfo.getProcessInstance(ProcessInstanceInfo.java:144)<br>
 at org.drools.persistence.processinstance.JPAProcessInstanceManager.getProcessInstance(JPAProcessInstanceManager.java:62)<br>
 at org.drools.common.AbstractWorkingMemory.getProcessInstance(AbstractWorkingMemory.java:1720)<br>
 at org.drools.impl.StatefulKnowledgeSessionImpl.getProcessInstance(StatefulKnowledgeSessionImpl.java:261)<br>
 at org.drools.command.runtime.process.GetProcessInstanceCommand.execute(GetProcessInstanceCommand.java:29)<br>
 at org.drools.command.runtime.process.GetProcessInstanceCommand.execute(GetProcessInstanceCommand.java:12)<br>
 at org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:254)<br>
 at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.getProcessInstance(CommandBasedStatefulKnowledgeSession.java:92)<br>
 at com.csatp.svc.rulesmgr.claim.ClaimsDemoJpaTest.validateDocumentWorkflow2(ClaimsDemoJpaTest.java:182)<br>
<br>
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.<br>
<br>
I don&#39;t know if it helps, but here is the forEach node from the flow:<br>
<br>
&lt;forEach id=&quot;2&quot; name=&quot;ForEach&quot; x=&quot;423&quot; y=&quot;62&quot; width=&quot;200&quot; height=&quot;150&quot; variableName=&quot;role&quot; collectionExpression=&quot;claim.roles&quot; &gt;<br>
&lt;nodes&gt;<br>
&lt;subProcess id=&quot;1&quot; name=&quot;Document Workflow&quot; x=&quot;36&quot; y=&quot;40&quot; width=&quot;132&quot; height=&quot;48&quot; processId=&quot;DocumentWorkflow2&quot; &gt;<br>
&lt;mapping type=&quot;in&quot; from=&quot;role&quot; to=&quot;role&quot; /&gt;<br>
&lt;/subProcess&gt;<br>
&lt;/nodes&gt;<br>
&lt;connections&gt;<br>
&lt;/connections&gt;<br>
&lt;in-ports&gt;<br>
&lt;in-port type=&quot;DROOLS_DEFAULT&quot; nodeId=&quot;1&quot; nodeInType=&quot;DROOLS_DEFAULT&quot; /&gt;<br>
&lt;/in-ports&gt;<br>
&lt;out-ports&gt;<br>
&lt;out-port type=&quot;DROOLS_DEFAULT&quot; nodeId=&quot;1&quot; nodeOutType=&quot;DROOLS_DEFAULT&quot; /&gt;<br>
&lt;/out-ports&gt;<br>
&lt;/forEach&gt;<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br><br clear="all"><br>-- <br> - <a href="http://salaboy.wordpress.com">http://salaboy.wordpress.com</a><br> - <a href="http://www.jbug.com.ar">http://www.jbug.com.ar</a><br> - Salatino &quot;Salaboy&quot; Mauricio -<br>