Search code examples
jboss7.xdroolsbusiness-rules

Drools rule error "Unexpected global"


I have business rules implemented in Drools, while executing I get java RuntimeException

Unexpected global [myService]
org.drools.common.AbstractWorkingMemory.setGlobal(AbstractWorkingMemory.java:588)

What could be the cause?

Rule:

rule "Tax Rule"
  when
    calculateTax : calculateTax(
        objOne : objOne,
        objTwo : objTwo,
        objThree : objThree
    );

    objFour : objFour();
    System.out.println("debug");

  then
    ...
end

Solution

  • I found the problem. I had few System.out.println() and one of them was at the place shown below. Removing that solved the problem.

    rule "Tax Rule"
      when
        calculateTax : calculateTax(
            objOne : objOne,
            objTwo : objTwo,
            objThree : objThree
        );
    
        objFour : objFour();
        System.out.println("debug");
    
      then
        ...
    end