I am trying to pass an slf4j Logger object to my Drools rule as a global.
In my calling Java class I define the logger and pass it to the rule via the setGlobal kie server command:
private static final Logger LOGGER = LoggerFactory.getLogger(KieServerTester.class);
Command<?> setGlobalCommand = commandsFactory.newSetGlobal("logger", LOGGER);
commands.add(setGlobalCommand);
And in my rule file I have the global defined as:
global org.slf4j.Logger logger;
However when I execute the command I get this error:
ERROR [org.kie.server.services.drools.DroolsKieContainerCommandServiceImpl] (default task-1) Error calling container 'mycontainer': java.lang.RuntimeException: Illegal class for global. Expected [org.slf4j.Logger], found [java.util.LinkedHashMap].
I have no idea where it's getting LinkedHashMap from. I have stepped through the calling code but can't see where the map appears.
If I change my global in the rule file to be a LinkedHashMap, I don't get the error. So somehow it looks like my logger object in the Java class is being converted to a LinkedHashMap.
Any help appreciated, thanks.