With a StatelessKnowledgeSession you are supposed to insert all of your facts
you want in Working Memory via the execute method call, and you don't insert
any facts later on.
What you want to do needs a StatefulKnowledgeSession.
-W
On 17/04/2012, Shur, Bob <robert.shur(a)hp.com> wrote:
I'm repeating this post because I didn't get an answer last
time. Is this
the wrong place to report a bug? If so, where is the right place? I'm trying
to understand whether this is really a bug or whether I'm doing something
wrong.
I have what looks to me like a Drools bug on a simple drl with declared
classes. I'm using version drools-distribution-5.3.0.Final.
I'm invoking it with this:
StatelessKnowledgeSession ksession =
kbase.newStatelessKnowledgeSession();
List<Object> facts = new ArrayList<Object>();
ksession.execute( facts );
=============================
I get this crash:
Exception in thread "main" java.lang.NoClassDefFoundError: com/sample/Cap
at ASMAccessorImpl_129541121334339192620.getValue(Unknown Source)
at
org.mvel2.optimizers.dynamic.DynamicGetAccessor.getValue(DynamicGetAccessor.java:73)
at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:103)
at
org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:42)
at org.mvel2.MVEL.executeExpression(MVEL.java:952)
...
==========================
Here's the drl file:
package com.sample
import com.sample.*;
declare Item
id : int;
end
declare Priority
name : String;
priority : int;
end
declare Cap
item : Item;
name : String
end
rule "split cart into items"
when
then
insert(new Item(1));
insert(new Item(2));
insert(new Item(3));
end
rule "Priorities"
when
then
insert(new Priority("A", 3));
insert(new Priority("B", 2));
insert(new Priority("C", 5));
end
rule "Caps"
when
$i : Item()
$p : Priority($name : name)
then
insert(new Cap($i, $name));
end
rule "test"
when
$i : Item()
Cap(item.id == $i.id)
then
System.out.println("Cap");
end
====================
Some observations:
- If I comment out any of the insert lines, the crash goes away
- If I change the first field of class Cap to be id:int instead of item:Item
and make the corresponding changes, the crash goes away
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users