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.
Some of the steps I followed: - Eliminate test harness. I added a main in my test class and simply instantiated that class and called the method directly. - Executed in different environment. Changed from Intellij Idea IDE, to Eclipse IDE. Have not tried command line. - 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. - In my application, removed all other rules, global, unused declarations. Further, I pruned down the offending rule to rudimentary instructions. 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? Thank you, Roger On Sat, May 10, 2014 at 11:06 AM, Mark Proctor <mproc...@codehaus.org>wrote: > 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 <ro...@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@lists.jboss.org > > https://lists.jboss.org/mailman/listinfo/rules-dev > > > _______________________________________________ > rules-dev mailing list > rules-dev@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-dev > -- Roger Lefebvre President, Precipice Technologies Inc. (e) ro...@precipicetech.com (c) 403 466 2622 (f) 403 475 0566
_______________________________________________ rules-dev mailing list rules-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-dev