In terms of your problem, it seems to be to do with:<br>PreventieveInsluitingsTitel<div id="mb_0">(previous==secondPosition<br>the secondPosition is not a compatible class with previous?<br><br>I don&#39;t have any specific thoughts on computing a sequence in rules, unfortunately... maybe someone else does ? ;)
<br><br><br></div><br><br><div><span class="gmail_quote">On 1/11/07, <b class="gmail_sendername">Joost de Vries</b> &lt;<a href="mailto:drools@ziener.org">drools@ziener.org</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>I&#39;m new to jBoss Rules and I&#39;m hitting a few snags. I appreciate your insight.<br><br>Among other things I want to use business rules to compute the right sequence of actions that conforms to legal business rules.
<br>The only way I could think of to implement this using rules is to use rewriting production rules similar to:<br>input: ACCAAAC<br>rule:&nbsp; CA -&gt; AC<br><br>My first question is: what other ways are there to compute a sequence that conforms to sequencing business rules?
<br><br>My second question concerns the nullpointerexceptions and classcastexceptions I&#39;m encountering in my rules.<br>I&#39;ve got a sequence of C&#39;s who are either B&#39;s or A&#39;s. I.e. C is the common superclass. This superclass has the methods:
<br><br>public C getPrevious();<br>public C getNext();<br><br>Actually it&#39;s in dutch so it&#39;s<br><br>public class Straf extends InsluitingsTitel {}<br>and<br>public class PreventieveInsluitingsTitel extends InsluitingsTitel {} 
<br>and <br>public abstract class InsluitingsTitel{<br>public C getPrevious();<br>
public C getNext();<br>
}<br><br>The rule is as follows:<br><br>rule &quot;WSV 68.1&quot;<br>&nbsp;&nbsp;&nbsp; when<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // any PreventieveInsluitingsTitel should precede all Straf<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; secondPosition: Straf ( firstPosition: previous ) <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; thirdPosition: PreventieveInsluitingsTitel(previous==secondPosition, fourthPosition:next)
<br>&nbsp;&nbsp;&nbsp; then<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println( &quot;switching wsv 68.1 &quot;+secondPosition+&quot; &quot;+thirdPosition); <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; thirdPosition.switchWithPrevious();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(firstPosition!=null){<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; modify(firstPosition);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; modify( secondPosition);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; modify( thirdPosition); <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(fourthPosition!=null){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //in the next statement a classcastexception is thrown<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; modify(fourthPosition); <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  
<br>end <br><br>results in a classcastexception. The sequence is at that moment { Straf, Straf, PreventieveInsluitingsTitel, Straf }&nbsp; and the middle two items are matched by the LHS secondPosition and thirdPosition.<br><br>

Here&#39;s the stacktrace.<br><br>java.lang.ClassCastException: org.dji.domein.insgro.Straf<br>&nbsp;&nbsp;&nbsp; at org.drools.base.org.dji.domein.insgro.PreventieveInsluitingsTitel$getPrevious.getValue(Unknown Source)<br>&nbsp;&nbsp;&nbsp; at org.drools.base.ClassFieldExtractor.getValue

(Unknown Source)<br>&nbsp;&nbsp;&nbsp; at org.drools.rule.Declaration.getValue(Unknown Source)<br>&nbsp;&nbsp;&nbsp; at com.sample.Rule_WSV_68_1_0ConsequenceInvoker.evaluate(Rule_WSV_68_1_0ConsequenceInvoker.java:22)<br>&nbsp;&nbsp;&nbsp; at org.drools.common.DefaultAgenda.fireActivation

(Unknown Source)<br>&nbsp;&nbsp;&nbsp; at org.drools.common.DefaultAgenda.fireNextItem(Unknown Source)<br>&nbsp;&nbsp;&nbsp; at org.drools.common.AbstractWorkingMemory.fireAllRules(Unknown Source)<br>&nbsp;&nbsp;&nbsp; at org.drools.common.AbstractWorkingMemory.fireAllRules

(Unknown Source)<br>&nbsp;&nbsp;&nbsp; at org.dji.domein.insgro.VolgordeTest.main(VolgordeTest.java:32)<br>org.drools.spi.ConsequenceException: java.lang.ClassCastException: org.dji.domein.insgro.Straf<br>&nbsp;&nbsp;&nbsp; at org.drools.common.DefaultAgenda.fireActivation

(Unknown Source)<br>&nbsp;&nbsp;&nbsp; at org.drools.common.DefaultAgenda.fireNextItem(Unknown Source)<br>&nbsp;&nbsp;&nbsp; at org.drools.common.AbstractWorkingMemory.fireAllRules(Unknown Source)<br>&nbsp;&nbsp;&nbsp; at org.drools.common.AbstractWorkingMemory.fireAllRules

(Unknown Source)<br>&nbsp;&nbsp;&nbsp; at org.dji.domein.insgro.VolgordeTest.main(VolgordeTest.java:32)<br>Caused by: java.lang.ClassCastException: org.dji.domein.insgro.Straf<br>&nbsp;&nbsp;&nbsp; at org.drools.base.org.dji.domein.insgro.PreventieveInsluitingsTitel$getNext.getValue

(Unknown Source)<br>&nbsp;&nbsp;&nbsp; at org.drools.base.ClassFieldExtractor.getValue(Unknown Source)<br>&nbsp;&nbsp;&nbsp; at org.drools.rule.Declaration.getValue(Unknown Source)<br>&nbsp;&nbsp;&nbsp; at com.sample.Rule_WSV_68_1_0ConsequenceInvoker.evaluate(Rule_WSV_68_1_0ConsequenceInvoker.java:22)
<br>&nbsp;&nbsp;&nbsp; ... 5 more<br clear="all"><br>Thanks in advance for your insight.<br><br>Regards,<br><br>-- <br><span class="sg">Joost de Vries<br><br>

</span><br>_______________________________________________<br>rules-users mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br><br><br></blockquote></div>
<br>