I am trying to get a project that runs in Drools 3 working on Drools 4.
Several of the rules in our DRL file are failing for the same reason,
which is described below. I have searched for documentation where
someone encountered this error, but have found none, which is why I am
writing the list.
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(Ba
seObjectClassFieldExtractor.java:106)
at
org.drools.base.ClassFieldExtractor.getLongValue(ClassFieldExtractor.jav
a:203)
at
org.drools.rule.VariableRestriction$LongVariableContextEntry.updateFromT
uple(VariableRestriction.java:284)
at
org.drools.common.SingleBetaConstraints.updateFromTuple(SingleBetaConstr
aints.java:100)
at org.drools.reteoo.JoinNode.assertTuple(JoinNode.java:102)
at
org.drools.reteoo.CompositeTupleSinkAdapter.createAndPropagateAssertTupl
e(CompositeTupleSinkAdapter.java:73)
at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode
.java:116)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(Compo
siteObjectSinkAdapter.java:318)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:140)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(Compo
siteObjectSinkAdapter.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.jav
a:909)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.jav
a:881)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.jav
a:67)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.jav
a: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_0Consequen
ceInvoker.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(AbstractWorkingMemo
ry.java:471)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemo
ry.java:433)
at
com.bah.aims.rules.compiler.SensorPairRulesTest.testNotInFileIqcrm(Senso
rPairRulesTest.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)
...