Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-44

ClassCastException with OR statements

XMLWordPrintable

      Rules combined with OR and AND clauses and PROBABLY global variables throw a ClassCastException.
      This issue is raised due to the discussion in user-list
      http://drools.46999.n3.nabble.com/ClassCastException-after-migrating-from-Drools-4-x-to-v5-5-td4022292.html

      I attached an isolated test.

      This is the error that I get:

      Caused by: org.drools.RuntimeDroolsException: com.test.drools.Rule_employeeContributionStartDateAfterAccountStartDate_ff664e4a040442f190ea42829e28cdd1Eval1Invoker@d3924bb
      c : java.lang.ClassCastException: com.test.drools.EmployeeDetailsRulesModel cannot be cast to com.test.drools.Account
      at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:119)
      at org.drools.reteoo.EvalConditionNode.assertLeftTuple(EvalConditionNode.java:176)
      at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:196)
      at org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:71)
      at org.drools.reteoo.JoinNode.propagateFromRight(JoinNode.java:159)
      at org.drools.reteoo.JoinNode.assertObject(JoinNode.java:148)
      at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
      at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
      at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
      at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
      at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:350)
      at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:311)
      at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
      at org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:192)
      at org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:186)
      at com.test.drools.Rule_employeePreloadSystemConstants_fa8d3c7c3b23439db5734ab24bd05240.defaultConsequence(Rule_employeePreloadSystemConstants_fa8d3c7c3b23439db57
      34ab24bd05240.java:7)
      at com.test.drools.Rule_employeePreloadSystemConstants_fa8d3c7c3b23439db5734ab24bd05240DefaultConsequenceInvokerGenerated.evaluate(Unknown Source)
      at com.test.drools.Rule_employeePreloadSystemConstants_fa8d3c7c3b23439db5734ab24bd05240DefaultConsequenceInvoker.evaluate(Unknown Source)
      at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287)
      ... 37 more
      Caused by: java.lang.ClassCastException: com.test.drools.EmployeeDetailsRulesModel cannot be cast to com.test.drools.Account
      at org.drools.base.com.test.drools.Account1369078346$getAccountStartDate.getValue(Unknown Source)
      at org.drools.base.ClassFieldReader.getValue(ClassFieldReader.java:87)
      at org.drools.rule.Declaration.getValue(Declaration.java:233)
      at com.test.drools.Rule_employeeContributionStartDateAfterAccountStartDate_ff664e4a040442f190ea42829e28cdd1Eval1InvokerGenerated.evaluate(Unknown Source)
      at com.test.drools.Rule_employeeContributionStartDateAfterAccountStartDate_ff664e4a040442f190ea42829e28cdd1Eval1Invoker.evaluate(Unknown Source)
      at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:114)
      ... 55 more

              mfusco@redhat.com Mario Fusco
              mnrz_jira Mohammad Norouzi (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: