Space characters between "(" and the type of local variable declaration in the enhanced "for" (foreach) statement causes a compilation error.

Solution Unverified - Updated -


Building a maven project containing rules using the enhanced for (foreach) statement in MVEL dialect with executable rule model disabled sometimes fails.

For example, my project contains a rule written in MVEL dialect like below and uses the enhanced for statement at (*1).

dialect "mvel"

rule "bus1"
        $buses : ArrayList() from collect ( Bus() )
        for ( Bus bus : $buses ) {    .......... (*1)
            System.out.println("bus: " + bus);

When I build the project with executable rule model disabled, a compilation error occurs with the following error message.

$ mvn clean compile exec:exec -DgenerateModel=NO
[ERROR] Unable to build KieBaseModel:rules
Unable to Analyse Expression for ( Bus bus : $buses ) {            System.out.println("bus: " + bus);        };:
[Error: cannot resolve identifier: Bu]
[Near : {... for ( Bus bus : $buses ) { ....}]
[Line: 8, Column: 0] : [Rule name='bus1']

[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.504 s
[INFO] Finished at: 2020-11-18T13:00:35+09:00
[INFO] ------------------------------------------------------------------------


  • Red Hat Decision Manager (RHDM)
    • 7.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content