I am using Drools 4.0.3. I have a rule that I believe should work but
causes a NullPointerException at runtime.
The rule phrased this way causes a NullPointerException:
rule "Create Order Limit"
when
CandleSeries( $instrument : instrumentSpecification )
then
insert(new OrderConstraint( $instrument ));
end
While the same rule phased like this works fine:
rule "Create Order Limit"
when
$candle : CandleSeries( )
then
insert(new OrderConstraint( $candle.getInstrumentSpecification()
));
end
Is this right? I was looking at rule example 10.27 in the Drools guide
and it's written exactly like rule #1 is.
Here is the full stack trace of the rule execution from version 1:
java.lang.NullPointerException
at
org.activequant.core.domainmodel.TimeSeries.getInstrumentSpecification(Unknown
Source)
at
org.drools.base.org.activequant.core.domainmodel.CandleSeries2216507$getInstrumentSpecification.getValue(Unknown
Source)
at
org.drools.base.ClassFieldExtractor.getValue(ClassFieldExtractor.java:127)
at org.drools.rule.Declaration.getValue(Declaration.java:197)
at
sequitem.quanteq.ruleflow.Rule_Create_Order_Limit_0ConsequenceInvoker.evaluate(Rule_Create_Order_Limit_0ConsequenceInvoker.java:17)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:550)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:514)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:462)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:424)
at
sequitem.quanteq.rules.engine.StatefulEngine.execute(StatefulEngine.java:50)
at
sequitem.quanteq.rules.engine.StatefulEngine.execute(StatefulEngine.java:24)
at
sequitem.quanteq.rules.RandomMarketEntryRulesTest.testRandomMarketEntryRules(RandomMarketEntryRulesTest.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at junit.textui.TestRunner.doRun(TestRunner.java:109)
at junit.textui.TestRunner.run(TestRunner.java:77)
at junit.textui.TestRunner.run(TestRunner.java:62)
at
sequitem.quanteq.rules.RandomMarketEntryRulesTest.main(RandomMarketEntryRulesTest.java:63)
E
Time: 36.687
There was 1 error:
1)
testRandomMarketEntryRules(sequitem.quanteq.rules.RandomMarketEntryRulesTest)org.drools.spi.ConsequenceException:
java.lang.NullPointerException
at
org.drools.base.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:14)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:553)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:514)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:462)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:424)
at
sequitem.quanteq.rules.engine.StatefulEngine.execute(StatefulEngine.java:50)
at
sequitem.quanteq.rules.engine.StatefulEngine.execute(StatefulEngine.java:24)
at
sequitem.quanteq.rules.RandomMarketEntryRulesTest.testRandomMarketEntryRules(RandomMarketEntryRulesTest.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at
sequitem.quanteq.rules.RandomMarketEntryRulesTest.main(RandomMarketEntryRulesTest.java:63)
Caused by: java.lang.NullPointerException
at
org.activequant.core.domainmodel.TimeSeries.getInstrumentSpecification(Unknown
Source)
at
org.drools.base.org.activequant.core.domainmodel.CandleSeries2216507$getInstrumentSpecification.getValue(Unknown
Source)
at
org.drools.base.ClassFieldExtractor.getValue(ClassFieldExtractor.java:127)
at org.drools.rule.Declaration.getValue(Declaration.java:197)
at
sequitem.quanteq.ruleflow.Rule_Create_Order_Limit_0ConsequenceInvoker.evaluate(Rule_Create_Order_Limit_0ConsequenceInvoker.java:17)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:550)
... 23 more