"ClassCastException" when modifying a fact involved in an 'or' condition in BRMS 6.3.x

Solution Verified - Updated -


  • Red Hat JBoss BRMS (BRMS) 6.3.0


A ClassCastException error is thrown by trying to use OR condition in when part of a rule as follows:

rule "sample"
       $tx: (Text (id=='foo') or Text (id=='bar')) 
       $m: Message()
       modify($m) {setText($tx)};

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.


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.