<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:'times new roman', 'new york', times, serif;font-size:10pt"><div>I think I have an AspectJ based solution for this which consists on&nbsp;making every isAllowed* method &nbsp;return "false" instead of letting exceptions thrown inside them propagate:</div><div><br></div><div><div>&nbsp;&nbsp; &nbsp;pointcut isAllowed(Object o) : execution(boolean *.isAllowed*(..)) &amp;&amp; target(o);&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp;boolean around(Object o) : isAllowed(o) {&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;boolean r= false;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;//debug("-&gt; "+ o.getClass().getName()+ "#"+ thisJoinPoint.getSignature().getName()+ "("+ thisJoinPoint.getSourceLocation().getLine()+ ")");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp;
 &nbsp;try{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;r= proceed(o);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//debug("&lt;- "+ o.getClass().getName()+ "#"+ thisJoinPoint.getSignature().getName()+ "("+ thisJoinPoint.getSourceLocation().getLine()+ ")");</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}catch(Exception e){</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//debug("&lt;- "+ o.getClass().getName()+ "#"+ thisJoinPoint.getSignature().getName()+ "("+ thisJoinPoint.getSourceLocation().getLine()+ "): "+ e.getMessage());</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;executeLHSExceptionHandlers(o, e);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return r;</div><div>&nbsp;&nbsp; &nbsp;}</div></div><div><br></div><div>AFAIK, it impacts classes implementing AlphaNodeFieldConstraint, BetaNodeFieldConstraint and Restriction
 interfaces.</div><div>I'd appreciate comments/improvements on this (ie, more detailed information for the exception handlers).</div><div><br></div><div>Kind regards.</div><div style="font-family:times new roman, new york, times, serif;font-size:10pt"><br><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">De:</span></b> Wolfgang Laun &lt;wolfgang.laun@gmail.com&gt;<br><b><span style="font-weight: bold;">Para:</span></b> Rules Users List &lt;rules-users@lists.jboss.org&gt;<br><b><span style="font-weight: bold;">Enviado:</span></b> mié,27 abril, 2011 09:13<br><b><span style="font-weight: bold;">Asunto:</span></b> Re: [rules-users] NullPointer after inserting fact in RHS<br></font><br><div>The location of the NPE suggests that some field (mmlCommandUid) is null<br>when you insert the object, but some rule wants to access its intValue.<br><br>All
 fields accessed in all rules must be initialized properly; Drools does not<br>
guard field accesses with "!= null" for you.<br><br>-W<br><br>&nbsp;</div><div class="gmail_quote">On 26 April 2011 20:27, dabar <span dir="ltr">&lt;<a rel="nofollow" ymailto="mailto:david.barrett.0%2Bdrools@gmail.com" target="_blank" href="mailto:david.barrett.0%2Bdrools@gmail.com">david.barrett.0+drools@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex;">I've been battling with drools and just wanting a second viewpoint. &nbsp;I'm<br>
using drools 5.2.0 flow and rules.<br>
<br>
I have a rule that inserts a new fact as part of the RHS of the rule and<br>
then I'm getting a null pointer exception - stack below. I assume when the<br>
fact is inserted all the rules are evaluated to build up the agenda.<br>
<br>
I've debugged through drools code and found that in ClassFieldReader object1<br>
is null and object2 is my new fact.<br>
<br>
I'm interested in what a JoinNode represents as I think this is what is<br>
being evaluated. I would guess its a join node in the flow but these don't<br>
contain any rules so perhaps not.<br>
<br>
Similar threads here suggest this is a fault in one of the rules but I have<br>
about 100 rules so working out the culprit isn't straightforward.<br>
What I really want to know is if there a way I can find out which rule is<br>
being assessed for the agenda so I check that rule.<br>
<br>
<br>
Caused by: java.lang.NullPointerException<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at<br>
org.drools.base.com.somecompany.prov.rulesbased.facts.ProvResponse1649170666$getMmlCommandUid.getIntValue(Unknown<br>
Source)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at<br>
org.drools.base.ClassFieldReader.getIntValue(ClassFieldReader.java:165)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at<br>
org.drools.base.evaluators.EqualityEvaluatorsDefinition$IntegerEqualEvaluator.evaluate(EqualityEvaluatorsDefinition.java:1522)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at<br>
org.drools.core.util.AbstractHashTable$SingleIndex.equal(AbstractHashTable.java:619)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at<br>
org.drools.core.util.LeftTupleList.matches(LeftTupleList.java:190)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at<br>
org.drools.core.util.LeftTupleIndexHashTable.getOrCreate(LeftTupleIndexHashTable.java:347)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at<br>
org.drools.core.util.LeftTupleIndexHashTable.add(LeftTupleIndexHashTable.java:233)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:65)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at<br>
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:189)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at<br>
org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:138)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at<br>
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:148)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at<br>
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:450)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at<br>
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:378)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at<br>
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:190)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at<br>
org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:145)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at<br>
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1183)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at<br>
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1085)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at<br>
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:889)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at<br>
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:238)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at<br>
com.somecompany.rules.global.RulesUtils.insertFact(RulesUtils.java:159)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at<br>
com.somecompany.rules.common.Rule_Common_HandleUnexpectedResponse___Mark_an_unexpected_response_as_handled_0.defaultConsequence(Rule_Common_HandleUnexpectedResponse___Mark_an_unexpected_response_as_handled_0.java:28)<br>

<font color="#888888"><br>
<br>
--<br>
View this message in context: <a rel="nofollow" target="_blank" href="http://drools.46999.n3.nabble.com/NullPointer-after-inserting-fact-in-RHS-tp2866772p2866772.html">http://drools.46999.n3.nabble.com/NullPointer-after-inserting-fact-in-RHS-tp2866772p2866772.html</a><br>

Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a rel="nofollow" ymailto="mailto:rules-users@lists.jboss.org" target="_blank" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a rel="nofollow" target="_blank" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>
</div></div><div style="position:fixed"></div>


</div></body></html>