I created a drool file PersonTotalAccountsBalance.drl as below. I am beginner in the rules engine world.
package com.auhuman.rules;
import com.auhuman.Person;
import com.auhuman.Account;
function float getTotalBalance(Person person) {
float totalBalance = 0;
for (Account account : person.getAccounts()){
totalBalance += account.getBalance();
}
return totalBalance;
}
rule "PersonTotalAccountsBalance"
when
$node : Person(active == true)
then
float totalBalance = getTotalBalance($node)
modify($node) {
setTotalBalance(totalBalance);
}
end
Upon compile I am getting below error
Unable to compile the file: PersonTotalAccountsBalance.drl. Errors = [Unable to find @positional field 0 for class Person
: [Rule name='PersonTotalAccountsBalance']
]
Although this question is very old:
I had the same error message but I was working with decision tables in xls
(excel) format. The table looked like this:
Note that $order:Order
is in a merged cell goes across both the CONDITION
and the ACTION
columns. That cell is only allowed to be above CONDITION
tables, not the ACTION
tables. After unmerging I didn't get the error anymore:
I got a very similar error when defining the wrong values in the ACTION
column for setting an attribute. When using values without quotes for a String
attribute in the model Order
I got the following error:
Unable to get KieModule, Errors Existed: Error Messages:
Message [id=1, kieBase=defaultKieBase, level=ERROR, path=status_rules/status.xls, line=21, column=0
text=Rule Compilation error The method setNextStatus(String) in the type Order is not applicable for the arguments (int)]
Message [id=2, kieBase=defaultKieBase, level=ERROR, path=status_rules/status.xls, line=5, column=0
text=Rule Compilation error The method setNextStatus(String) in the type Order is not applicable for the arguments (int)]
Message [id=3, kieBase=defaultKieBase, level=ERROR, path=status_rules/status.xls, line=13, column=0
text=Rule Compilation error The method setNextStatus(String) in the type Order is not applicable for the arguments (int)]
However in this case the error message was more precise.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With