org.kuali.rice.krms.api.engine.IncompatibleTypeException: Could not compare values for operator org.kuali.rice.krms.framework.engine.expression.DefaultComparisonOperator@3c876818 -> Type should have been one of [java.lang.String] but was java.lang.Boolean

Kuali JIRA | Eric Westfall | 5 years ago
  1. 0

    To reproduce this problem, create a term specification and term with a type of java.lang.Boolean. Then create a rule in the UI that compares that term to see if it's equal to "true". If you pass in the fact value for the term as a boolean (which the engine supports) then it doesn't work because SimplePropositionType always creates constants of type String instead of looking at the data type of the term specification associated with the term. So you end up with an exception like the following (note that there is some attempt to coerce the RHS going on inside DefaultComparisonOperator but this doesn't appear to make a difference): {code} org.kuali.rice.krms.api.engine.IncompatibleTypeException: Could not compare values for operator org.kuali.rice.krms.framework.engine.expression.DefaultComparisonOperator@3c876818 -> Type should have been one of [java.lang.String] but was java.lang.Boolean at org.kuali.rice.krms.framework.engine.expression.DefaultComparisonOperator.coerceRhs(DefaultComparisonOperator.java:97) at org.kuali.rice.krms.framework.engine.expression.DefaultComparisonOperator.compare(DefaultComparisonOperator.java:47) at org.kuali.rice.krms.framework.engine.expression.ComparisonOperatorServiceImpl.compare(ComparisonOperatorServiceImpl.java:86) at org.kuali.rice.krms.framework.engine.expression.ComparisonOperator.compare(ComparisonOperator.java:114) at org.kuali.rice.krms.framework.engine.expression.BinaryOperatorExpression.invoke(BinaryOperatorExpression.java:48) at org.kuali.rice.krms.framework.engine.expression.BinaryOperatorExpression.invoke(BinaryOperatorExpression.java:26) at org.kuali.rice.krms.framework.engine.expression.BooleanValidatingExpression.invoke(BooleanValidatingExpression.java:41) at org.kuali.rice.krms.framework.engine.expression.BooleanValidatingExpression.invoke(BooleanValidatingExpression.java:27) at org.kuali.rice.krms.framework.engine.expression.ExpressionBasedProposition.evaluate(ExpressionBasedProposition.java:44) at org.kuali.rice.krms.impl.provider.repository.LazyProposition.evaluate(LazyProposition.java:52) at org.kuali.rice.krms.framework.engine.CompoundProposition.evaluateInner(CompoundProposition.java:92) at org.kuali.rice.krms.framework.engine.CompoundProposition.evaluate(CompoundProposition.java:63) at org.kuali.rice.krms.impl.provider.repository.LazyProposition.evaluate(LazyProposition.java:52) at org.kuali.rice.krms.framework.engine.BasicRule.evaluate(BasicRule.java:64) at org.kuali.rice.krms.impl.provider.repository.LazyRule.evaluate(LazyRule.java:53) at org.kuali.rice.krms.framework.engine.BasicAgendaTreeEntry.execute(BasicAgendaTreeEntry.java:59) at org.kuali.rice.krms.framework.engine.BasicAgendaTree.execute(BasicAgendaTree.java:55) at org.kuali.rice.krms.impl.provider.repository.LazyAgendaTree.execute(LazyAgendaTree.java:43) at org.kuali.rice.krms.framework.engine.BasicAgenda.execute(BasicAgenda.java:46) at org.kuali.rice.krms.framework.engine.BasicContext.execute(BasicContext.java:51) at org.kuali.rice.krms.framework.engine.ProviderBasedEngine.execute(ProviderBasedEngine.java:68) at train.krms.test.RuleTest.testPatronInBadStanding(RuleTest.java:53) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) {code}

    Kuali JIRA | 5 years ago | Eric Westfall
    org.kuali.rice.krms.api.engine.IncompatibleTypeException: Could not compare values for operator org.kuali.rice.krms.framework.engine.expression.DefaultComparisonOperator@3c876818 -> Type should have been one of [java.lang.String] but was java.lang.Boolean
  2. 0

    To reproduce this problem, create a term specification and term with a type of java.lang.Boolean. Then create a rule in the UI that compares that term to see if it's equal to "true". If you pass in the fact value for the term as a boolean (which the engine supports) then it doesn't work because SimplePropositionType always creates constants of type String instead of looking at the data type of the term specification associated with the term. So you end up with an exception like the following (note that there is some attempt to coerce the RHS going on inside DefaultComparisonOperator but this doesn't appear to make a difference): {code} org.kuali.rice.krms.api.engine.IncompatibleTypeException: Could not compare values for operator org.kuali.rice.krms.framework.engine.expression.DefaultComparisonOperator@3c876818 -> Type should have been one of [java.lang.String] but was java.lang.Boolean at org.kuali.rice.krms.framework.engine.expression.DefaultComparisonOperator.coerceRhs(DefaultComparisonOperator.java:97) at org.kuali.rice.krms.framework.engine.expression.DefaultComparisonOperator.compare(DefaultComparisonOperator.java:47) at org.kuali.rice.krms.framework.engine.expression.ComparisonOperatorServiceImpl.compare(ComparisonOperatorServiceImpl.java:86) at org.kuali.rice.krms.framework.engine.expression.ComparisonOperator.compare(ComparisonOperator.java:114) at org.kuali.rice.krms.framework.engine.expression.BinaryOperatorExpression.invoke(BinaryOperatorExpression.java:48) at org.kuali.rice.krms.framework.engine.expression.BinaryOperatorExpression.invoke(BinaryOperatorExpression.java:26) at org.kuali.rice.krms.framework.engine.expression.BooleanValidatingExpression.invoke(BooleanValidatingExpression.java:41) at org.kuali.rice.krms.framework.engine.expression.BooleanValidatingExpression.invoke(BooleanValidatingExpression.java:27) at org.kuali.rice.krms.framework.engine.expression.ExpressionBasedProposition.evaluate(ExpressionBasedProposition.java:44) at org.kuali.rice.krms.impl.provider.repository.LazyProposition.evaluate(LazyProposition.java:52) at org.kuali.rice.krms.framework.engine.CompoundProposition.evaluateInner(CompoundProposition.java:92) at org.kuali.rice.krms.framework.engine.CompoundProposition.evaluate(CompoundProposition.java:63) at org.kuali.rice.krms.impl.provider.repository.LazyProposition.evaluate(LazyProposition.java:52) at org.kuali.rice.krms.framework.engine.BasicRule.evaluate(BasicRule.java:64) at org.kuali.rice.krms.impl.provider.repository.LazyRule.evaluate(LazyRule.java:53) at org.kuali.rice.krms.framework.engine.BasicAgendaTreeEntry.execute(BasicAgendaTreeEntry.java:59) at org.kuali.rice.krms.framework.engine.BasicAgendaTree.execute(BasicAgendaTree.java:55) at org.kuali.rice.krms.impl.provider.repository.LazyAgendaTree.execute(LazyAgendaTree.java:43) at org.kuali.rice.krms.framework.engine.BasicAgenda.execute(BasicAgenda.java:46) at org.kuali.rice.krms.framework.engine.BasicContext.execute(BasicContext.java:51) at org.kuali.rice.krms.framework.engine.ProviderBasedEngine.execute(ProviderBasedEngine.java:68) at train.krms.test.RuleTest.testPatronInBadStanding(RuleTest.java:53) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) {code}

    Kuali JIRA | 5 years ago | Eric Westfall
    org.kuali.rice.krms.api.engine.IncompatibleTypeException: Could not compare values for operator org.kuali.rice.krms.framework.engine.expression.DefaultComparisonOperator@3c876818 -> Type should have been one of [java.lang.String] but was java.lang.Boolean

    Root Cause Analysis

    1. org.kuali.rice.krms.api.engine.IncompatibleTypeException

      Could not compare values for operator org.kuali.rice.krms.framework.engine.expression.DefaultComparisonOperator@3c876818 -> Type should have been one of [java.lang.String] but was java.lang.Boolean

      at org.kuali.rice.krms.framework.engine.expression.DefaultComparisonOperator.coerceRhs()
    2. org.kuali.rice
      ProviderBasedEngine.execute
      1. org.kuali.rice.krms.framework.engine.expression.DefaultComparisonOperator.coerceRhs(DefaultComparisonOperator.java:97)
      2. org.kuali.rice.krms.framework.engine.expression.DefaultComparisonOperator.compare(DefaultComparisonOperator.java:47)
      3. org.kuali.rice.krms.framework.engine.expression.ComparisonOperatorServiceImpl.compare(ComparisonOperatorServiceImpl.java:86)
      4. org.kuali.rice.krms.framework.engine.expression.ComparisonOperator.compare(ComparisonOperator.java:114)
      5. org.kuali.rice.krms.framework.engine.expression.BinaryOperatorExpression.invoke(BinaryOperatorExpression.java:48)
      6. org.kuali.rice.krms.framework.engine.expression.BinaryOperatorExpression.invoke(BinaryOperatorExpression.java:26)
      7. org.kuali.rice.krms.framework.engine.expression.BooleanValidatingExpression.invoke(BooleanValidatingExpression.java:41)
      8. org.kuali.rice.krms.framework.engine.expression.BooleanValidatingExpression.invoke(BooleanValidatingExpression.java:27)
      9. org.kuali.rice.krms.framework.engine.expression.ExpressionBasedProposition.evaluate(ExpressionBasedProposition.java:44)
      10. org.kuali.rice.krms.impl.provider.repository.LazyProposition.evaluate(LazyProposition.java:52)
      11. org.kuali.rice.krms.framework.engine.CompoundProposition.evaluateInner(CompoundProposition.java:92)
      12. org.kuali.rice.krms.framework.engine.CompoundProposition.evaluate(CompoundProposition.java:63)
      13. org.kuali.rice.krms.impl.provider.repository.LazyProposition.evaluate(LazyProposition.java:52)
      14. org.kuali.rice.krms.framework.engine.BasicRule.evaluate(BasicRule.java:64)
      15. org.kuali.rice.krms.impl.provider.repository.LazyRule.evaluate(LazyRule.java:53)
      16. org.kuali.rice.krms.framework.engine.BasicAgendaTreeEntry.execute(BasicAgendaTreeEntry.java:59)
      17. org.kuali.rice.krms.framework.engine.BasicAgendaTree.execute(BasicAgendaTree.java:55)
      18. org.kuali.rice.krms.impl.provider.repository.LazyAgendaTree.execute(LazyAgendaTree.java:43)
      19. org.kuali.rice.krms.framework.engine.BasicAgenda.execute(BasicAgenda.java:46)
      20. org.kuali.rice.krms.framework.engine.BasicContext.execute(BasicContext.java:51)
      21. org.kuali.rice.krms.framework.engine.ProviderBasedEngine.execute(ProviderBasedEngine.java:68)
      21 frames
    3. train.krms.test
      RuleTest.testPatronInBadStanding
      1. train.krms.test.RuleTest.testPatronInBadStanding(RuleTest.java:53)
      1 frame
    4. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    5. JUnit
      InvokeMethod.evaluate
      1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
      2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
      4. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      4 frames
    6. Spring TestContext
      SpringJUnit4ClassRunner.runChild
      1. org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
      2. org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
      3. org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
      4. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
      4 frames
    7. JUnit
      ParentRunner$2.evaluate
      1. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
      2. org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
      3. org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
      4. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
      5. org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
      6. org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
      6 frames
    8. Spring TestContext
      RunAfterTestClassCallbacks.evaluate
      1. org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      2. org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
      2 frames
    9. JUnit
      ParentRunner.run
      1. org.junit.runners.ParentRunner.run(ParentRunner.java:300)
      1 frame
    10. Spring TestContext
      SpringJUnit4ClassRunner.run
      1. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
      1 frame
    11. JUnit4 Runner
      JUnit4TestReference.run
      1. org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      1 frame
    12. JUnit3 Runner
      RemoteTestRunner.main
      1. org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      2. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      3. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      4. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      5. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
      5 frames