Hi all,

I'm trying to migrate my JBoss v3.0.6 rules to the latest v4.0.0 release. I could already resolve some issues but now I'm already stuck for hours with a NullPointerException that I can't get rid of. I broke the problem down to a relatively small set of test files that I'd like to show you here:


/* SimpleTest.java */
package com.sample;
// ... imports removed for brevity
public class SimpleTest {
  public static final void main(String[] args) throws Exception {
    PackageBuilder builder = new PackageBuilder();
    builder.addPackageFromDrl(new InputStreamReader(SimpleTest.class
        .getResourceAsStream("/rf1.drl")));
    builder.addPackageFromDrl(new InputStreamReader(SimpleTest.class
        .getResourceAsStream("/rf2.drl")));
    RuleBase rb = RuleBaseFactory.newRuleBase();
    rb.addPackage(builder.getPackage());
    WorkingMemory wm = rb.newStatefulSession();
    wm.insert(new Task()); // <-- crashes here
    wm.fireAllRules();
  }
}


/* Task.java */
package com.sample;
public class Task {
  private String next = null;
  public String getNext() {
    return next;
  }
  public void setNext(String next) {
    this.next = next;
  }
}


// rf1.drl
package com.sample
rule "r0"
  when
        Task( next == null ); # <-- change to "x"
  then
        System.out.println("r0");
end
rule "r1"
  when
        Task( next == "1" );
  then
        System.out.println("r1");
end


// rf2.drl
package com.sample
rule "r2"
  when
        Task( next == "2" );
  then
        System.out.println("r1");
end


As you can see there are two Drools rule files and two Java classes. If I run the SimpleTest class, I get the following exception:

Exception in thread "main" java.lang.NullPointerException
at org.drools.reteoo.CompositeObjectSinkAdapter$HashKey.equals(CompositeObjectSinkAdapter.java:608) at org.drools.util.AbstractHashTable$EqualityEquals.equal(AbstractHashTable.java:345)
        at org.drools.util.ObjectHashMap.get(ObjectHashMap.java:86)
at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:295)
        at 
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:168)
        at org.drools.reteoo.Rete.assertObject(Rete.java:168)
        at 
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:190)
at org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:70) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:848) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:822) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:623)
        at com.sample.SimpleTest.main(SimpleTest.java:22)

I've marked the position in the source code at which the run crashes. Does anybody have an idea what's wrong here?

Some more strange things relating to this problem:
* If I change the 'null' in rf1.drl to '""' (empty string), the problem remains. * If I change the 'null' in rf1.drl to '"x"' (or some other non-empty string), then the exception is gone.
 * If I remove any of the two rule files, the exception is gone, too.

Any ideas? Should I file a bug?

Thanks in advance!

Cheers,
Christian
begin:vcard
fn:Christian Spurk
n:Spurk;Christian
org:DFKI GmbH;Language Technology Lab
adr;quoted-printable:;;Stuhlsatzenhausweg 3;Saarbr=C3=BCcken;;66123;Germany
email;internet:[EMAIL PROTECTED]
title:Dipl.-Ling. (Computerlinguistik)
tel;work:+49681/302-5354
note;quoted-printable:Deutsches Forschungszentrum f=C3=BCr K=C3=BCnstliche Intelligenz GmbH=0D=0A=
	Firmensitz: Trippstadter Stra=C3=9Fe 122, D-67663 Kaiserslautern=0D=0A=
	=0D=0A=
	Gesch=C3=A4ftsf=C3=BChrung:=0D=0A=
	Prof. Dr. Dr. h.c. mult. Wolfgang Wahlster (Vorsitzender),=0D=0A=
	Dr. Walter Olthoff=0D=0A=
	=0D=0A=
	Vorsitzender des Aufsichtsrats:=0D=0A=
	Prof. Dr. h.c. Hans A. Aukes=0D=0A=
	=0D=0A=
	Amtsgericht Kaiserslautern, HRB 2313=0D=0A=
	
x-mozilla-html:FALSE
version:2.1
end:vcard

_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to