The
most likely reason for this is that one of your rules is trying to evaluate a
value which is null. The when part of a rule is evaluated as the
fact is inserted and may be evaluated even if the then part will never be
reached.
Looking
at your stack trace it looks like the rule involved may have a NOT in it.
Have a careful look through your rules and see if there is a case where a null
pointer may occur and/or try removing them one by one until it stops breaking,
if that doesn’t work can you post your rules as well.
Thomas
From:
rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org]
On Behalf Of Sebastian Furth
Sent: 23 March 2010
13:11
To: rules-users@lists.jboss.org
Subject: [rules-users]
NullPointerException while inserting Facts
Hi,
we are currently trying to integrate DROOLS 5.1 in
our project.
In our Project we have two different kinds of Facts, called
Values and Inputs. We don't have any problems with inserting Input instances but
sometimes when we try to insert an instance of the Value class (@see: http://www.pastie.org/private/juv7hh7rxahpluo5agu3q)
we get the following
NullPointerException:
java.lang.NullPointerException
at org.drools.reteoo.LeftTuple.get(LeftTuple.java:265)
at
org.drools.reteoo.LeftTuple.get(LeftTuple.java:300)
at
org.drools.rule.VariableRestriction$ObjectVariableContextEntry.updateFromTuple(VariableRestriction.java:320)
at
org.drools.common.SingleBetaConstraints.updateFromTuple(SingleBetaConstraints.java:119)
at
org.drools.reteoo.NotNode.assertLeftTuple(NotNode.java:98)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:117)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:34)
at
org.drools.reteoo.NotNode.assertLeftTuple(NotNode.java:123)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:145)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:57)
at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:142)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)
at
org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:147)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:360)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:344)
at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:185)
at
org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:146)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1046)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1001)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:788)
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:216)
at
de.d3web.we.drools.DroolsAction.addFacts(DroolsAction.java:296)
at
de.d3web.we.drools.DroolsAction.createKnowledgeSession(DroolsAction.java:268)
at de.d3web.we.drools.DroolsAction.execute(DroolsAction.java:67)
The
weird thing is that we don't get this exception with all instances of the Value
class - some of them can be inserted, others not. The objects are created
correctly - we've already debugged this. The crash happens somewhere deeper in
the drools api.
It would be really great if you could give us a
hint how we could fix this problem.
Thank you in advance.
Best
regards
Sebastian Furth