'Mismatched input in rule of drools

I am trying to run my rule set but it shows :

ERROR[102]

I added ")" where it is missing and after that The error said that it was in ")" [the added ")" in $transfer1 block]

rule "balanceTransfers"
when
    $bus1 : CloudBus();
    $bus2 : CloudBus(id > $bus1.id);
    $transfers1: Number() from accumulate( 
        CloudRoute(bus == $bus1, count(1))
    $transfers2: Number() from accumulate( //<-line 51
        CloudRoute(bus == $bus2, count(1)
then
    scoreHolder.addSoftConstraintMatch(kcontext, -Math.abs($transfers1 - 
      $transfers2));
end

Exception in thread "Thread-114" java.lang.IllegalStateException: There are errors in a score DRL: Error Messages: Message [id=1, kieBase=defaultKieBase, level=ERROR, path=..., line=51, column=0
text=[ERR 102] Line 51:1 mismatched input '$transfers2' in rule "balanceTransfers"] Message [id=2, kieBase=defaultKieBase, level=ERROR, path=..., line=0, column=0 text=Parser returned a null Package]



Solution 1:[1]

The accumulate syntax is wrong. It should be accumulate ( Pattern(), fc()). You are not closing the parenthesis of the pattern:

rule "balanceTransfers"
when
    $bus1 : CloudBus();
    $bus2 : CloudBus(id > $bus1.id);
    $transfers1: Number() from accumulate( 
        CloudRoute(bus == $bus1), 
        count(1)
    )
    $transfers2: Number() from accumulate(
        CloudRoute(bus == $bus2), 
        count(1)
    )
then
    scoreHolder.addSoftConstraintMatch(kcontext, -Math.abs($transfers1 - 
      $transfers2));
end

Hope it helps,

Solution 2:[2]

When I helped a college with this error, it was that there was a missing end on the previous rule.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Esteban Aliverti
Solution 2 Grallen