Here is a sample rule that fails:
rule 'X'
salience 750
when
s : Sensor( source == "Not in File" , TCN matches
"CRM[0-9]+MXFS[0-9]+" )
then
System.out.println("Rule executed: X " );
s.setSource("X");
System.out.println( "in rule location 2");
update(s);
System.out.println( "in rule
location 3");
end
The rule fails when the "update(s);" statement is executed, with the error that a String cannot be converted to a long (stack trace is below). The Sensor class has several variables. The last getter method called before the failure returns a long. The source variable (which is set in the RHS of the rule) is a String , and the for source is the 2nd to last getter called.
Does anyone have an idea why this update statement would fail - why it would be trying to convert a String to a long?
Thank
you,
David Warren
Stack trace:
org.drools.RuntimeDroolsException:
Conversion to long not supported from java.lang.String
at
org.drools.base.extractors.BaseObjectClassFieldExtractor.getLongValue(BaseObjectClassFieldExtractor.java:106)
at
org.drools.base.ClassFieldExtractor.getLongValue(ClassFieldExtractor.java:203)
at
org.drools.rule.VariableRestriction$LongVariableContextEntry.updateFromTuple(VariableRestriction.java:284)
at
org.drools.common.SingleBetaConstraints.updateFromTuple(SingleBetaConstraints.java:100)
at
org.drools.reteoo.JoinNode.assertTuple(JoinNode.java:102)
at
org.drools.reteoo.CompositeTupleSinkAdapter.createAndPropagateAssertTuple(CompositeTupleSinkAdapter.java:73)
at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:116)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:318)
at
org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:140)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:299)
at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:153)
at
org.drools.reteoo.Rete.assertObject(Rete.java:175)
at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
at
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:71)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:909)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:881)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:67)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:61)
at
com.bah.aims.rules.Rule_X_0.consequence(Rule_X_0.java:32)
at
com.bah.aims.rules.Rule_X_0ConsequenceInvoker.evaluate(Rule_X_0ConsequenceInvoker.java:22)
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:471)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:433)
at
com.bah.aims.rules.compiler.SensorPairRulesTest.testNotInFileIqcrm(SensorPairRulesTest.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)
at
java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
...