Search code examples
javadroolsbusiness-rulesdrools-fusion

"no viable alternative at input n" and "mismatched input"


I have the following class

public class DroolsObjectRule {

    private String backend;
    private Long time;
    private Long avgTime;
    private boolean allow=true;
    private String message;

    //Set

    //Get
}

My rule

rule "rule_3_increment_more"
  salience 3
  when
    $drol: DroolsObjectRule(backend == "AD1" &&  (2 * $drol.avgTime) > $drol.time) [this is line 33]
  then
    $drol.setMessage("RULE 3");
end

When I run the code I get the following error

Caused by: java.lang.IllegalArgumentException: 
 [33,48]: [ERR 101] Line 33:48 no viable alternative at input '2'
          in rule "rule_3_increment_more" in pattern DroolsObjectRule
 [33,79]: [ERR 102] Line 33:79 mismatched input ')' expecting '('
          in rule "rule_3_increment_more" in pattern DroolsObjectRule in pattern $drol.time

Any idea?


Solution

  • The rule works correctly in 5.3.0, 5.6.0, 5.5.0, 6.0.0 and 6.1.0.

    If you use an older version, stick to the legacy form of constraints:

    DroolsObjectRule( backend == "AD1", $avgTime: avgTime,
                      time < 2*$avgTime )