"ClassCastException" when modifying a fact involved in an 'or' condition in BRMS 6.3.x
Environment
- Red Hat JBoss BRMS (BRMS) 6.3.0
Issue
A ClassCastException
error is thrown by trying to use OR
condition in when part of a rule as follows:
rule "sample"
no-loop
when
$tx: (Text (id=='foo') or Text (id=='bar'))
$m: Message()
then
modify($m) {setText($tx)};
end
The root cause is a ClassCastException
:
Caused by: java.lang.ClassCastException: com.sample.Message cannot be cast to org.drools.core.common.InternalFactHandle
at org.drools.core.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:398)
The same rule works well with BRMS 6.2 libraries.
Resolution
This issue has been fixed in Red Hat JBoss BRMS Update 1. Please apply it or any latest update for 6.3.x and try again.
A workaround for previous versions would be to split the rules into two rules or use ||
instead as follows:
$tx: Text (id=='foo' || id=='bar')
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments