Hi,

I'm new to jBoss Rules and I'm hitting a few snags. I appreciate your insight.

Among other things I want to use business rules to compute the right sequence of actions that conforms to legal business rules.
The only way I could think of to implement this using rules is to use rewriting production rules similar to:
input: ACCAAAC
rule:  CA -> AC

My first question is: what other ways are there to compute a sequence that conforms to sequencing business rules?

My second question concerns the nullpointerexceptions and classcastexceptions I'm encountering in my rules.
I've got a sequence of C's who are either B's or A's. I.e. C is the common superclass. This superclass has the methods:

public C getPrevious();
public C getNext();

Actually it's in dutch so it's

public class Straf extends InsluitingsTitel {}
and
public class PreventieveInsluitingsTitel extends InsluitingsTitel {}
and
public abstract class InsluitingsTitel{
public C getPrevious();
public C getNext();
}

The rule is as follows:

rule "WSV 68.1"
    when
        // any PreventieveInsluitingsTitel should precede all Straf
        secondPosition: Straf ( firstPosition: previous )
        thirdPosition: PreventieveInsluitingsTitel(previous==secondPosition, fourthPosition:next)
    then
        System.out.println( "switching wsv 68.1 "+secondPosition+" "+thirdPosition);
        thirdPosition.switchWithPrevious();
        if(firstPosition!=null){
            modify(firstPosition);
        }
        modify( secondPosition);
        modify( thirdPosition);
        if(fourthPosition!=null){
            //in the next statement a classcastexception is thrown
            modify(fourthPosition);
        }      
end

results in a classcastexception. The sequence is at that moment { Straf, Straf, PreventieveInsluitingsTitel, Straf }  and the middle two items are matched by the LHS secondPosition and thirdPosition.

Here's the stacktrace.

java.lang.ClassCastException: org.dji.domein.insgro.Straf
    at org.drools.base.org.dji.domein.insgro.PreventieveInsluitingsTitel$getPrevious.getValue(Unknown Source)
    at org.drools.base.ClassFieldExtractor.getValue (Unknown Source)
    at org.drools.rule.Declaration.getValue(Unknown Source)
    at com.sample.Rule_WSV_68_1_0ConsequenceInvoker.evaluate(Rule_WSV_68_1_0ConsequenceInvoker.java:22)
    at org.drools.common.DefaultAgenda.fireActivation (Unknown Source)
    at org.drools.common.DefaultAgenda.fireNextItem(Unknown Source)
    at org.drools.common.AbstractWorkingMemory.fireAllRules(Unknown Source)
    at org.drools.common.AbstractWorkingMemory.fireAllRules (Unknown Source)
    at org.dji.domein.insgro.VolgordeTest.main(VolgordeTest.java:32)
org.drools.spi.ConsequenceException: java.lang.ClassCastException: org.dji.domein.insgro.Straf
    at org.drools.common.DefaultAgenda.fireActivation (Unknown Source)
    at org.drools.common.DefaultAgenda.fireNextItem(Unknown Source)
    at org.drools.common.AbstractWorkingMemory.fireAllRules(Unknown Source)
    at org.drools.common.AbstractWorkingMemory.fireAllRules (Unknown Source)
    at org.dji.domein.insgro.VolgordeTest.main(VolgordeTest.java:32)
Caused by: java.lang.ClassCastException: org.dji.domein.insgro.Straf
    at org.drools.base.org.dji.domein.insgro.PreventieveInsluitingsTitel$getNext.getValue (Unknown Source)
    at org.drools.base.ClassFieldExtractor.getValue(Unknown Source)
    at org.drools.rule.Declaration.getValue(Unknown Source)
    at com.sample.Rule_WSV_68_1_0ConsequenceInvoker.evaluate(Rule_WSV_68_1_0ConsequenceInvoker.java:22)
    ... 5 more

Thanks in advance for your insight.

Regards,

--
Joost de Vries