Christian,

   Yes, looks like a bug. Can you please open a JIRA for it?

   Thank you,
       Edson


2007/7/27, Christian Spurk < Christian.Spurk@dfki.de>:
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

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users





--
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  JBoss, a division of Red Hat @ www.jboss.com