<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial, helvetica, sans-serif;font-size:12pt"><DIV>I think I have the variables covered, and no changes to the class hierarchies (and the flows work without persistenence still).&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>My variable Claim is declared in the top level process as com.csatp.svc.rulesmgr.claim.Claim, my variable Role is declared in the subprocess as com.csatp.svc.rulesmgr.claim.Role.</DIV>
<DIV>&nbsp;</DIV>
<DIV>The stack got buried in my overly long original post, here it is:</DIV>
<DIV>&nbsp;</DIV>
<DIV>java.lang.ClassCastException: org.drools.workflow.instance.node.ForEachNodeInstance cannot be cast to org.drools.workflow.instance.node.CompositeContextNodeInstance<BR>&nbsp;at org.drools.persistence.processinstance.ProcessInstanceInfo.restoreVariable(ProcessInstanceInfo.java:198)<BR>&nbsp;at org.drools.persistence.processinstance.ProcessInstanceInfo.restoreVariables(ProcessInstanceInfo.java:166)<BR>&nbsp;at org.drools.persistence.processinstance.ProcessInstanceInfo.getProcessInstance(ProcessInstanceInfo.java:144)<BR>&nbsp;at org.drools.persistence.processinstance.JPAProcessInstanceManager.getProcessInstance(JPAProcessInstanceManager.java:62)<BR>&nbsp;at org.drools.common.AbstractWorkingMemory.getProcessInstance(AbstractWorkingMemory.java:1720)<BR>&nbsp;at org.drools.impl.StatefulKnowledgeSessionImpl.getProcessInstance(StatefulKnowledgeSessionImpl.java:261)<BR>&nbsp;at
 org.drools.command.runtime.process.GetProcessInstanceCommand.execute(GetProcessInstanceCommand.java:29)<BR>&nbsp;at org.drools.command.runtime.process.GetProcessInstanceCommand.execute(GetProcessInstanceCommand.java:12)<BR>&nbsp;at org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:254)<BR>&nbsp;at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.getProcessInstance(CommandBasedStatefulKnowledgeSession.java:92)<BR>&nbsp;at com.csatp.svc.rulesmgr.claim.ClaimsDemoJpaTest.validateDocumentWorkflow2(ClaimsDemoJpaTest.java:182)<BR></DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>&nbsp;</DIV>
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif; FONT-SIZE: 12pt"><BR>
<DIV style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt"><FONT size=2 face=Tahoma>
<HR SIZE=1>
<B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> Mauricio Salatino &lt;salaboy@gmail.com&gt;<BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> Rules Users List &lt;rules-users@lists.jboss.org&gt;<BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Mon, October 19, 2009 1:40:37 PM<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re: [rules-users] [droolsflow] JPAVariablePersister - ClassCastException on ForEachNodeInstance<BR></FONT><BR>I'm trying to remember what's the problem..<BR>But for what I remember it could be something like: <BR>you define the variable claim with type <FONT size=+0><FONT size=2><U>com</U>.<U>csatp</U>.<U>svc</U>.<U>rulesmgr</U>.claim.Claim</FONT></FONT><BR><BR>did you change the variable type, for example adding a new variable from a different type into the claim variable?<BR><BR>if not, can you post the stack trace about the class cast exception?<BR>to know about from which class is trying to
 cast...<BR><BR><BR><BR><BR>
<DIV class=gmail_quote>2009/10/19 Bill Tarr <SPAN dir=ltr>&lt;<A href="mailto:javatestcase@yahoo.com" rel=nofollow target=_blank ymailto="mailto:javatestcase@yahoo.com">javatestcase@yahoo.com</A>&gt;</SPAN><BR>
<BLOCKQUOTE style="BORDER-LEFT: rgb(204,204,204) 1px solid; MARGIN: 0pt 0pt 0pt 0.8ex; PADDING-LEFT: 1ex" class=gmail_quote>
<DIV>
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif; FONT-SIZE: 12pt">
<DIV>Could you clarify what you mean by defining the variables?</DIV>
<DIV>&nbsp;</DIV>
<DIV>Are you referring to the header variable definitions?</DIV>
<DIV>&nbsp;</DIV><FONT size=2>
<P align=left>&lt;variables&gt;</P>
<P align=left>&lt;variable name="claim" &gt;</P>
<P align=left>&lt;type name="<U>org</U>.drools.process.core.<U>datatype</U>.<U>impl</U>.type.ObjectDataType" className="<U>com</U>.<U>csatp</U>.<U>svc</U>.<U>rulesmgr</U>.claim.Claim" /&gt;</P>
<P align=left>&lt;/variable&gt;</P>
<P>&lt;/variables&gt;</P>
<P></P></FONT>&nbsp; 
<P>If so, could you clarify what should be added?</P>
<DIV><BR></DIV>
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif; FONT-SIZE: 12pt"><BR>
<DIV style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt"><FONT size=2 face=Tahoma>
<HR SIZE=1>
<B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> Mauricio Salatino &lt;<A href="mailto:salaboy@gmail.com" rel=nofollow target=_blank ymailto="mailto:salaboy@gmail.com">salaboy@gmail.com</A>&gt;<BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> Rules Users List &lt;<A href="mailto:rules-users@lists.jboss.org" rel=nofollow target=_blank ymailto="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</A>&gt;<BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Mon, October 19, 2009 12:59:51 PM<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re: [rules-users] [droolsflow] JPAVariablePersister - ClassCastException on ForEachNodeInstance<BR></FONT>
<DIV>
<DIV></DIV>
<DIV class=h5><BR>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" rel=nofollow target=_blank ymailto="mailto:javatestcase@yahoo.com">javatestcase@yahoo.com</A>&gt;</SPAN> wrote:<BR>
<BLOCKQUOTE style="BORDER-LEFT: rgb(204,204,204) 1px solid; MARGIN: 0pt 0pt 0pt 0.8ex; PADDING-LEFT: 1ex" class=gmail_quote>This seems more like a bug, I thought I'd post it here, but&nbsp;point me&nbsp;to the JIRA if I need to enter an issue.<BR><BR>Still testing out JPAVariablePersister.&nbsp; It appears the session, processes,&nbsp;and variables are persisted.&nbsp; However, when I try to load the session again, and reopen the process as follows, I get a ClassCastException.<BR><BR>&nbsp;&nbsp;&nbsp; StatefulKnowledgeSession session = JPAKnowledgeService.loadStatefulKnowledgeSession( 1, knowledgeBase, null, env );<BR>&nbsp;&nbsp;&nbsp; ProcessInstance processClm = session.getProcessInstance(1);<BR><BR>The second line (ClaimsDemoJpaTest.java:182) is the source of the stack trace below.&nbsp; The error makes sense, as:<BR><BR>&nbsp;&nbsp;ForEachNodeInstance extends CompositeNodeInstance<BR>&nbsp; CompositeContextNodeInstance extends
 CompositeNodeInstance<BR><BR>So they clearly cannot be cast to each other, but I'm not of how to troubleshoot this beyond that.&nbsp; The line of code throwing the error clearly expects to be able to cast the nodeInstance.<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;restoreVariable(variableInfo, parentIds, variableName,&nbsp;(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>&nbsp;at org.drools.persistence.processinstance.ProcessInstanceInfo.restoreVariable(ProcessInstanceInfo.java:198)<BR>&nbsp;at org.drools.persistence.processinstance.ProcessInstanceInfo.restoreVariables(ProcessInstanceInfo.java:166)<BR>&nbsp;at org.drools.persistence.processinstance.ProcessInstanceInfo.getProcessInstance(ProcessInstanceInfo.java:144)<BR>&nbsp;at
 org.drools.persistence.processinstance.JPAProcessInstanceManager.getProcessInstance(JPAProcessInstanceManager.java:62)<BR>&nbsp;at org.drools.common.AbstractWorkingMemory.getProcessInstance(AbstractWorkingMemory.java:1720)<BR>&nbsp;at org.drools.impl.StatefulKnowledgeSessionImpl.getProcessInstance(StatefulKnowledgeSessionImpl.java:261)<BR>&nbsp;at org.drools.command.runtime.process.GetProcessInstanceCommand.execute(GetProcessInstanceCommand.java:29)<BR>&nbsp;at org.drools.command.runtime.process.GetProcessInstanceCommand.execute(GetProcessInstanceCommand.java:12)<BR>&nbsp;at org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:254)<BR>&nbsp;at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.getProcessInstance(CommandBasedStatefulKnowledgeSession.java:92)<BR>&nbsp;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't know if it helps, but here is the forEach node from the flow:<BR><BR>&lt;forEach id="2" name="ForEach" x="423" y="62" width="200" height="150" variableName="role" collectionExpression="claim.roles" &gt;<BR>&lt;nodes&gt;<BR>&lt;subProcess id="1" name="Document Workflow" x="36" y="40" width="132" height="48" processId="DocumentWorkflow2" &gt;<BR>&lt;mapping type="in" from="role" to="role" /&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="DROOLS_DEFAULT" nodeId="1" nodeInType="DROOLS_DEFAULT" /&gt;<BR>&lt;/in-ports&gt;<BR>&lt;out-ports&gt;<BR>&lt;out-port type="DROOLS_DEFAULT" nodeId="1" nodeOutType="DROOLS_DEFAULT"
 /&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" rel=nofollow target=_blank ymailto="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</A><BR><A href="https://lists.jboss.org/mailman/listinfo/rules-users" rel=nofollow target=_blank>https://lists.jboss.org/mailman/listinfo/rules-users</A><BR></BLOCKQUOTE></DIV><BR><BR clear=all><BR>-- <BR>- http://salaboy.wordpress.com<BR>- http://www.jbug.com.ar<BR>- Salatino "Salaboy" Mauricio -<BR></DIV></DIV></DIV></DIV></DIV><BR></DIV><BR>_______________________________________________<BR>rules-users mailing list<BR><A href="mailto:rules-users@lists.jboss.org" rel=nofollow target=_blank ymailto="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</A><BR><A href="https://lists.jboss.org/mailman/listinfo/rules-users" rel=nofollow
 target=_blank>https://lists.jboss.org/mailman/listinfo/rules-users</A><BR><BR></BLOCKQUOTE></DIV><BR><BR clear=all><BR>-- <BR>- <A href="http://salaboy.wordpress.com/" rel=nofollow target=_blank>http://salaboy.wordpress.com</A><BR>- <A href="http://www.jbug.com.ar/" rel=nofollow target=_blank>http://www.jbug.com.ar</A><BR>- Salatino "Salaboy" Mauricio -<BR></DIV></DIV></div><br>



      </body></html>