[rules-users] java.lang.ClassCastException comparing BigDecimals (compareTo)

Michael Neale michael.neale at gmail.com
Wed Jan 30 04:58:24 EST 2008


hmmm... have you tried setting "dialect 'mvel' " for the rule/package?
I am not sure if you can do that even in java 5 (but in MVEL we can make it
happen if it doesn't already).

On Jan 25, 2008 11:19 PM, José Arrarte <jarrarte at gmail.com> wrote:

> Hello,
>
> First of all, I'd like to thank all the people involved in making this
> tool such a great one (this includes whoever writes the reference manual as
> well).
>
> I've been having some problems when comparing BigDecimals (using the
> compareTo method). I didn't find this issue in any previous post or in
> Drools' JIRA. However, I've been using Drools for a short time, so I hope
> you people can help me.
>
> The problem:
>
> Firing this (simple) rule:
>
> rule "Test Rule"
>   when
>       $dec : java.math.BigDecimal() from java.math.BigDecimal.TEN;
>       eval( $dec.compareTo(java.math.BigDecimal.ONE) > 0 )
>   then
>       System.out.println("OK!");
> end
>
> Fires this exception:
>
> org.drools.RuntimeDroolsException: java.lang.ClassCastException:
> java.lang.Integer cannot be cast to java.math.BigDecimal
> at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:76)
> at org.drools.reteoo.EvalConditionNode.assertTuple(EvalConditionNode.java:145)
>
> at org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple(
> SingleTupleSinkAdapter.java:20)
> at org.drools.reteoo.FromNode.assertTuple(FromNode.java:90)
> at org.drools.reteoo.SingleTupleSinkAdapter.createAndPropagateAssertTuple(
> SingleTupleSinkAdapter.java:55)
> at org.drools.reteoo.LeftInputAdapterNode.assertObject(
> LeftInputAdapterNode.java:116)
> at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(
> SingleObjectSinkAdapter.java:22)
> 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$WorkingMemoryReteAssertAction.execute
> (ReteooWorkingMemory.java:179)
> at org.drools.common.AbstractWorkingMemory.executeQueuedActions(
> AbstractWorkingMemory.java:1315)
> at org.drools.common.AbstractWorkingMemory.fireAllRules(
> AbstractWorkingMemory.java:462)
> at org.drools.common.AbstractWorkingMemory.fireAllRules(
> AbstractWorkingMemory.java:433)
> at com.sample.DroolsTest.main(DroolsTest.java:33)
> Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast
> to java.math.BigDecimal
> at com.sample.Rule_Test_Rule_0Eval0Invoker.evaluate(Rule_Test_Rule_0Eval0Invoker.java:12)
>
> at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:72)
> ... 14 more
>
> I've reported the issue in JIRA (
> http://jira.jboss.com/jira/browse/JBRULES-1433)
>
> Best regards,
> José
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
Michael D Neale
home: www.michaelneale.net
blog: michaelneale.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080130/f78e27e8/attachment.html 


More information about the rules-users mailing list