Can you upload with the jira issue an isolated test?<br><br><br><div class="gmail_quote">On Mon, Oct 19, 2009 at 1:55 PM, Mauricio Salatino <span dir="ltr">&lt;<a href="mailto:salaboy@gmail.com">salaboy@gmail.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;">Hmm I see.. that&#39;s another problem related with variable hierarchies inside the context.<br>
Because you are using a variable inside a node that contains a nested context, probably there is a problem when the algorithm looks for nested context.. I need to review that.. can you open a Jira Issue and assign it to me? (Mauricio Salatino) <br>
<div><div></div><div class="h5">
<br><br><div class="gmail_quote">2009/10/19 Bill Tarr <span dir="ltr">&lt;<a href="mailto:javatestcase@yahoo.com" target="_blank">javatestcase@yahoo.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div><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). </div>
<div> </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> </div>
<div>The stack got buried in my overly long original post, here it is:</div><div>
<div> </div>
<div>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>

</div>
<div> </div>
<div><br> </div>
</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 face="Tahoma" size="2"><div>
<hr size="1">
<b><span style="font-weight: bold;">From:</span></b> Mauricio Salatino &lt;<a href="mailto:salaboy@gmail.com" target="_blank">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" target="_blank">rules-users@lists.jboss.org</a>&gt;<br>

</div><b><span style="font-weight: bold;">Sent:</span></b> Mon, October 19, 2009 1:40:37 PM<div><div></div><div><br><b><span style="font-weight: bold;">Subject:</span></b> Re: [rules-users] [droolsflow] JPAVariablePersister - ClassCastException on ForEachNodeInstance<br>

</div></div></font><div><div></div><div><br>I&#39;m trying to remember what&#39;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">javatestcase@yahoo.com</a>&gt;</span><br>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); 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> </div>
<div>Are you referring to the header variable definitions?</div>
<div> </div><font size="2">
<p align="left">&lt;variables&gt;</p>
<p align="left">&lt;variable name=&quot;claim&quot; &gt;</p>
<p align="left">&lt;type name=&quot;<u>org</u>.drools.process.core.<u>datatype</u>.<u>impl</u>.type.ObjectDataType&quot; className=&quot;<u>com</u>.<u>csatp</u>.<u>svc</u>.<u>rulesmgr</u>.claim.Claim&quot; /&gt;</p>
<p align="left">&lt;/variable&gt;</p>
<p>&lt;/variables&gt;</p>
<p></p></font>  
<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 face="Tahoma" size="2">
<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">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">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><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">javatestcase@yahoo.com</a>&gt;</span> wrote:<br>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">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" rel="nofollow" target="_blank">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>- <a href="http://salaboy.wordpress.com" target="_blank">http://salaboy.wordpress.com</a><br>

- <a href="http://www.jbug.com.ar" target="_blank">http://www.jbug.com.ar</a><br>- Salatino &quot;Salaboy&quot; 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">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 &quot;Salaboy&quot; Mauricio -<br></div></div></div></div></div><br>



      </div><br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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>
<br></blockquote></div><br><br clear="all"><br>-- <br> - <a href="http://salaboy.wordpress.com" target="_blank">http://salaboy.wordpress.com</a><br> - <a href="http://www.jbug.com.ar" target="_blank">http://www.jbug.com.ar</a><br>
 - Salatino &quot;Salaboy&quot; Mauricio -<br>

</div></div></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>