Hello,

I am having some major problems working with dynamic rules. This may be a showstopper for us. Perhaps I have missed something in the docs.

The main problem is significantly different behavior depending on when I assert facts versus when I read drl files that use them.

It *appears* that I must class load all potential fact classes by referencing them in a dummy rule before I assert facts and and begin using dynamic rules against them. But that is a guess.

An example:

I have 2 rule files and 1 fact class (class factA with a String field1).

---------------------
testCase1.drl:
---------------------
rule Bootstrap
    when
        a : factA(field1=="blah")
    then
        System.out.println("bootstrap: a blah");
end
---------------------
testCase2.drl:
---------------------
rule "aIsHello"
    when
        a: factA(field1=="hello")
    then
        System.out.println("a: " + a.getField1());
        a.setField1("world");
        modify(a);
end

rule "aIsWorld"
    when
        a: factA(field1 == "world")
    then
        System.out.println("Retracted a with field1 = " + a.getField1());
        retract(a);
end


If I first assert my factA (workingMemory.assertObject( new factA("hello")) ) before loading either drl file, only rule "aIsHello" fires.

If I first load testCase1.drl and then assert factA and then load testCase2.drl, then both rule "aIsHello" and rule "aIsWorld" both fire. This is the expected behavior (at least for me).

If I modify testCase1.drl such that it does not reference class factA but some other class (e.g. factAtoo), then only rule "aIsHello" fires (as in the first case).

I am extremely confused, as I would at least expect the same behavior in all cases. For our application, it is critical that we be able to assert facts and modify rules independently and dynamically. What am I missing about how dynamic rules should work??

Any help is greatly appreciated!

Justine