Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-1428

ClassCastException when comparing BigDecimal fields

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Critical
    • Resolution: Done
    • Affects Version/s: 4.0.4
    • Fix Version/s: 4.0.5, 5.0.0.M1
    • Component/s: None
    • Labels:
      None

      Description

      Works on Drools 4.0.2 but not on Drools 4.0.4.

      java.lang.ClassCastException: java.lang.Long
      at org.drools.base.evaluators.BigDecimalFactory$BigDecimalGreaterEvaluator.evaluate(BigDecimalFactory.java:318)
      at org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:61)
      at org.drools.rule.LiteralConstraint.isAllowed(LiteralConstraint.java:82)
      at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:132)
      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.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.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:682)
      at com.sample.DroolsTest.main(DroolsTest.java:27)

      package com.sample
      import com.sample.DroolsTest.Message;
      rule "rule1"
      when
      Message(value > 0)
      then
      end

      public class DroolsTest
      {

      public static final void main(String[] args)
      {
      try

      { RuleBase ruleBase = readRule(); Message a = new Message(); a.setValue(new BigDecimal(0)); WorkingMemory workingMemory = ruleBase.newStatefulSession(); workingMemory.insert(a); workingMemory.fireAllRules(); }

      catch (Throwable t)

      { t.printStackTrace(); }

      }

      private static RuleBase readRule() throws Exception

      { Reader source = new InputStreamReader(DroolsTest.class.getResourceAsStream("/Sample.drl")); PackageBuilder builder = new PackageBuilder(); builder.addPackageFromDrl(source); Package pkg = builder.getPackage(); RuleBase ruleBase = RuleBaseFactory.newRuleBase(); ruleBase.addPackage(pkg); return ruleBase; }

      public static class Message
      {
      private BigDecimal value;

      public BigDecimal getValue()

      { return this.value; }

      public void setValue(BigDecimal value)

      { this.value = value; }

      }

      }

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                michaelneale Michael Neale
                Reporter:
                agattik Alexandre Gattiker
              • Votes:
                1 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: