[
https://issues.jboss.org/browse/DROOLS-600?page=com.atlassian.jira.plugin...
]
Mario Fusco resolved DROOLS-600.
--------------------------------
Fix Version/s: 6.2.0.CR1
Resolution: Done
Fixed by
https://github.com/droolsjbpm/drools/commit/3c124bee7
I fixed this because the fix was trivial and didn't make sense to leave it broken.
However be aware that:
1. FactTemplates are not a public feature and very likely they will be removed in one of
the next release. You can easily replace them with the more generic type declarations.
2. Not only FactTemplates but practically 100% of the code you're using in that code
snippet you sent belongs to Drools private (and very old) API. All those classes are
subject to disappear or to be heavily changed in a near future. I strongly suggest you to
migrate your code to the new kie/drools API available with Drools 6.x
I hope this helps.
ClassCastException when using FactTemplates
-------------------------------------------
Key: DROOLS-600
URL:
https://issues.jboss.org/browse/DROOLS-600
Project: Drools
Issue Type: Bug
Affects Versions: 6.1.0.Final
Reporter: Stephanie Kroll
Assignee: Mario Fusco
Fix For: 6.2.0.CR1
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.
{noformat}
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)
...{noformat}
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)