How to fix "Variables can not be used inside bindings" error in Drools ?
Issue
- When defining a new rule (like the following) in BRMS, it throws the latter given error message.
Rule:
package com.sample
import com.sample.Test;
rule "Test"
when
Test($firstVal : map.get("key"), $secondVal: map.get($firstVal))
then
System.out.println("Fired rule: Test");
end
Stacktrace:
Variables can not be used inside bindings. Variable [$firstVal] is being used in binding 'map.get($firstVal)' : [Rule name='Test']
java.lang.IllegalArgumentException: Could not parse knowledge.
at com.sample.Test.readKnowledgeBase(Test.java:41)
at com.sample.Test.main(Test.java:22)
...
How to fix this rule?
Environment
- Red Hat JBoss BRMS (BRMS)
- 5.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
