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

ClassCastException when using FactTemplates

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 6.2.0.CR1
    • 6.1.0.Final
    • None
    • None

      We have embedded Drools in our project and use FactTemplates. While attempting to upgrade from Drools 5.3 to 6.1, we are receiving a ClassCastException in org.drools.compiler.rule.builder.PatternBuilder when loading and compiling rules.

      The problem is evident upon inspection of the code. In method build(RuleBuildContext, BaseDescr, Pattern), the local var objectType can be either a FactTemplateObjectType or a ClassObjectType, but line 258 does not check the type before attempting the cast.

      java.lang.ClassCastException: org.drools.core.facttemplates.FactTemplateObjectType cannot be cast to org.drools.core.base.ClassObjectType
      	at org.drools.compiler.rule.builder.PatternBuilder.build(PatternBuilder.java:258)
      	at org.drools.compiler.rule.builder.PatternBuilder.build(PatternBuilder.java:138)
      	at org.drools.compiler.rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:66)
      	at org.drools.compiler.rule.builder.RuleBuilder.build(RuleBuilder.java:89)
      	at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.addRule(KnowledgeBuilderImpl.java:1652)
      	at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.compileRules(KnowledgeBuilderImpl.java:968)
      	at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.compileAllRules(KnowledgeBuilderImpl.java:844)
      	at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.addPackage(KnowledgeBuilderImpl.java:838)
      	at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.addPackageFromDrl(KnowledgeBuilderImpl.java:339)
      	at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.addPackageFromDrl(KnowledgeBuilderImpl.java:315)
      	...

              mfusco@redhat.com Mario Fusco
              skkroll Stephanie Kroll (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: