[rules-dev] Expression Timer NPE Drools 6.0.1.Final

Mark Proctor mproctor at codehaus.org
Sat May 10 13:06:39 EDT 2014


We have a number of unit tests for expressions:
https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/integrationtests/TimerAndCalendarTest.java

Could you add a unit test to demonstrate your problem, and submit it as a pull request?
http://docs.jboss.org/drools/release/5.5.0.Final/droolsjbpm-introduction-docs/html/gettingstarted.html

Mark
On 7 May 2014, at 21:36, rogerL <roger at precipicetech.com> wrote:

> Hello,
> 
> I'm encountering an NPE when attempting to use and expression timer in my
> rule.
> env:
> Drools 6.0.1.Final
> OS Maverick
> IDE Intellij Idea
> Java 7
> 
> Given the ebb and flow nature of the facts in the system, we want to be able
> to control the cycles dynamically. Hence the desire to use the expression
> timer.
> The expression that I tried is based on the 6.0.1 documentation.
> That is, something of the form *Timer(expr: $d, $p)*
> In an effort to get beyond the NPE, I tried playing around with the
> parameters by using combinations of both longs and appropriately formatted
> strings (e.g. 10s, 1m, etc), and using only the delay.
> I saw mention that a semicolon should follow the expression. That equally
> failed.
> The interval and cron timer variations, however, both work.
> 
> 
> The .drl and exception are:
> 
> declare SystemControlData
>    isEnabled : boolean = false
>    delay   : long = 30
>    period  : long = 60000
>    maxCallQueueDepth : int = 1
> end
> 
> 
> rule "If the system is enabled start campaign check at specified interval"
>    agenda-group "system_criteria"
> //    auto-focus true
>    salience 20
> //    timer( expr: $d, $p ) throws NPE
> //    timer( expr: $d; ) throws NPE
>    timer(cron:0/5 * * * * ?)
> when
>    SystemControlData(isEnabled==true, $d: delay, $p:period,
> maxCallQueueDepth>0)
> then
>    drools.setFocus( "campaign_criteria" );
> end
> 
> 
> 
> Exception in thread "SimpleAsyncTaskExecutor-1"
> java.lang.NullPointerException
> 	at
> org.drools.core.base.mvel.MVELCompilationUnit.createFactory(MVELCompilationUnit.java:262)
> 	at
> org.drools.core.base.mvel.MVELCompilationUnit.getFactory(MVELCompilationUnit.java:276)
> 	at
> org.drools.core.base.mvel.MVELObjectExpression.getValue(MVELObjectExpression.java:76)
> 	at org.drools.core.time.TimeUtils.evalTimeExpression(TimeUtils.java:140)
> 	at
> org.drools.core.time.impl.ExpressionIntervalTimer.createTrigger(ExpressionIntervalTimer.java:151)
> 	at
> org.drools.core.phreak.PhreakTimerNode.createTrigger(PhreakTimerNode.java:260)
> 	at
> org.drools.core.phreak.PhreakTimerNode.scheduleLeftTuple(PhreakTimerNode.java:230)
> 	at
> org.drools.core.phreak.PhreakTimerNode.doLeftInserts(PhreakTimerNode.java:93)
> 	at org.drools.core.phreak.PhreakTimerNode.doNode(PhreakTimerNode.java:69)
> 	at
> org.drools.core.phreak.RuleNetworkEvaluator.innerEval(RuleNetworkEvaluator.java:357)
> 	at
> org.drools.core.phreak.RuleNetworkEvaluator.outerEval(RuleNetworkEvaluator.java:161)
> 	at
> org.drools.core.phreak.RuleNetworkEvaluator.evaluateNetwork(RuleNetworkEvaluator.java:116)
> 	at
> org.drools.core.phreak.RuleExecutor.reEvaluateNetwork(RuleExecutor.java:200)
> 	at
> org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:67)
> 	at
> org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:935)
> 	at
> org.drools.core.common.DefaultAgenda.fireUntilHalt(DefaultAgenda.java:1160)
> 	at
> org.drools.core.common.AbstractWorkingMemory.fireUntilHalt(AbstractWorkingMemory.java:1002)
> 	at
> org.drools.core.common.AbstractWorkingMemory.fireUntilHalt(AbstractWorkingMemory.java:978)
> 	at
> org.drools.core.impl.StatefulKnowledgeSessionImpl.fireUntilHalt(StatefulKnowledgeSessionImpl.java:273)
> 
> 
> 
> --
> View this message in context: http://drools.46999.n3.nabble.com/Expression-Timer-NPE-Drools-6-0-1-Final-tp4029469.html
> Sent from the Drools: Developer (committer) mailing list mailing list archive at Nabble.com.
> _______________________________________________
> rules-dev mailing list
> rules-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev




More information about the rules-dev mailing list