]
Mario Fusco commented on DROOLS-600:
------------------------------------
Can you send a reproducer for this issue? I tried to reproduce this problem with the
following DRL but it works for me.
{code}
declare Bean @format( template )
value : String
end
rule Init when
then
insert( new Bean("test") );
end
rule R when
$b: Bean( value == "test" )
then
System.out.println("OK");
end
{code}
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: Mark Proctor
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}