How to fix "Variables can not be used inside bindings" error in Drools ?

Solution Unverified - Updated -

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, 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