<div dir="ltr">As suggested, I wrote some tests based on methods defined in the given class. That is, I extend from CommonTestMethodBase and used "loadKnowledgeBaseFromString(str)" to define the base for my KieSession. I was unable to reproduce the exception. I went through several cycles altering initializations, stripping down the rule, so forth but still to no avail. <div>
<br></div><div>Some of the steps I followed: </div><div>- Eliminate test harness. I added a main in my test class and simply instantiated that class and called the method directly.</div><div>- Executed in different environment. Changed from Intellij Idea IDE, to Eclipse IDE. Have not tried command line.</div>
<div>- In my application, I create the declared class externally and inject it into the engine The test method, on the other hand, injects the declared class via a high salience "init" rule. As such, I tried same approach in my application.</div>
<div>- In my application, removed all other rules, global, unused declarations. Further, I pruned down the offending rule to rudimentary instructions. </div><div><br></div><div>I have yet to dive into the drools/kie code to identify the differences, if any, between the test and application engine and rule initialization paths. Before I do, are there any suggestions on what other route I might take?</div>
<div><br></div><div>Thank you,</div><div><br></div><div>Roger</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, May 10, 2014 at 11:06 AM, Mark Proctor <span dir="ltr"><<a href="mailto:mproctor@codehaus.org" target="_blank">mproctor@codehaus.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We have a number of unit tests for expressions:<br>
<a href="https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/integrationtests/TimerAndCalendarTest.java" target="_blank">https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/integrationtests/TimerAndCalendarTest.java</a><br>
<br>
Could you add a unit test to demonstrate your problem, and submit it as a pull request?<br>
<a href="http://docs.jboss.org/drools/release/5.5.0.Final/droolsjbpm-introduction-docs/html/gettingstarted.html" target="_blank">http://docs.jboss.org/drools/release/5.5.0.Final/droolsjbpm-introduction-docs/html/gettingstarted.html</a><br>
<span class="HOEnZb"><font color="#888888"><br>
Mark<br>
</font></span><div class="HOEnZb"><div class="h5">On 7 May 2014, at 21:36, rogerL <<a href="mailto:roger@precipicetech.com">roger@precipicetech.com</a>> wrote:<br>
<br>
> Hello,<br>
><br>
> I'm encountering an NPE when attempting to use and expression timer in my<br>
> rule.<br>
> env:<br>
> Drools 6.0.1.Final<br>
> OS Maverick<br>
> IDE Intellij Idea<br>
> Java 7<br>
><br>
> Given the ebb and flow nature of the facts in the system, we want to be able<br>
> to control the cycles dynamically. Hence the desire to use the expression<br>
> timer.<br>
> The expression that I tried is based on the 6.0.1 documentation.<br>
> That is, something of the form *Timer(expr: $d, $p)*<br>
> In an effort to get beyond the NPE, I tried playing around with the<br>
> parameters by using combinations of both longs and appropriately formatted<br>
> strings (e.g. 10s, 1m, etc), and using only the delay.<br>
> I saw mention that a semicolon should follow the expression. That equally<br>
> failed.<br>
> The interval and cron timer variations, however, both work.<br>
><br>
><br>
> The .drl and exception are:<br>
><br>
> declare SystemControlData<br>
> isEnabled : boolean = false<br>
> delay : long = 30<br>
> period : long = 60000<br>
> maxCallQueueDepth : int = 1<br>
> end<br>
><br>
><br>
> rule "If the system is enabled start campaign check at specified interval"<br>
> agenda-group "system_criteria"<br>
> // auto-focus true<br>
> salience 20<br>
> // timer( expr: $d, $p ) throws NPE<br>
> // timer( expr: $d; ) throws NPE<br>
> timer(cron:0/5 * * * * ?)<br>
> when<br>
> SystemControlData(isEnabled==true, $d: delay, $p:period,<br>
> maxCallQueueDepth>0)<br>
> then<br>
> drools.setFocus( "campaign_criteria" );<br>
> end<br>
><br>
><br>
><br>
> Exception in thread "SimpleAsyncTaskExecutor-1"<br>
> java.lang.NullPointerException<br>
> at<br>
> org.drools.core.base.mvel.MVELCompilationUnit.createFactory(MVELCompilationUnit.java:262)<br>
> at<br>
> org.drools.core.base.mvel.MVELCompilationUnit.getFactory(MVELCompilationUnit.java:276)<br>
> at<br>
> org.drools.core.base.mvel.MVELObjectExpression.getValue(MVELObjectExpression.java:76)<br>
> at org.drools.core.time.TimeUtils.evalTimeExpression(TimeUtils.java:140)<br>
> at<br>
> org.drools.core.time.impl.ExpressionIntervalTimer.createTrigger(ExpressionIntervalTimer.java:151)<br>
> at<br>
> org.drools.core.phreak.PhreakTimerNode.createTrigger(PhreakTimerNode.java:260)<br>
> at<br>
> org.drools.core.phreak.PhreakTimerNode.scheduleLeftTuple(PhreakTimerNode.java:230)<br>
> at<br>
> org.drools.core.phreak.PhreakTimerNode.doLeftInserts(PhreakTimerNode.java:93)<br>
> at org.drools.core.phreak.PhreakTimerNode.doNode(PhreakTimerNode.java:69)<br>
> at<br>
> org.drools.core.phreak.RuleNetworkEvaluator.innerEval(RuleNetworkEvaluator.java:357)<br>
> at<br>
> org.drools.core.phreak.RuleNetworkEvaluator.outerEval(RuleNetworkEvaluator.java:161)<br>
> at<br>
> org.drools.core.phreak.RuleNetworkEvaluator.evaluateNetwork(RuleNetworkEvaluator.java:116)<br>
> at<br>
> org.drools.core.phreak.RuleExecutor.reEvaluateNetwork(RuleExecutor.java:200)<br>
> at<br>
> org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:67)<br>
> at<br>
> org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:935)<br>
> at<br>
> org.drools.core.common.DefaultAgenda.fireUntilHalt(DefaultAgenda.java:1160)<br>
> at<br>
> org.drools.core.common.AbstractWorkingMemory.fireUntilHalt(AbstractWorkingMemory.java:1002)<br>
> at<br>
> org.drools.core.common.AbstractWorkingMemory.fireUntilHalt(AbstractWorkingMemory.java:978)<br>
> at<br>
> org.drools.core.impl.StatefulKnowledgeSessionImpl.fireUntilHalt(StatefulKnowledgeSessionImpl.java:273)<br>
><br>
><br>
><br>
> --<br>
> View this message in context: <a href="http://drools.46999.n3.nabble.com/Expression-Timer-NPE-Drools-6-0-1-Final-tp4029469.html" target="_blank">http://drools.46999.n3.nabble.com/Expression-Timer-NPE-Drools-6-0-1-Final-tp4029469.html</a><br>
> Sent from the Drools: Developer (committer) mailing list mailing list archive at Nabble.com.<br>
> _______________________________________________<br>
> rules-dev mailing list<br>
> <a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
<br>
<br>
_______________________________________________<br>
rules-dev mailing list<br>
<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Roger Lefebvre<div>President, Precipice Technologies Inc.</div><div>(e) <a href="mailto:roger@precipicetech.com" target="_blank">roger@precipicetech.com</a></div>
<div>(c) 403 466 2622</div><div>(f) 403 475 0566</div></div>
</div>