Search code examples
droolsjava-17

XLS decision table doesn't work on 8.32.0.Final


I tried to run the latest version of drools (8.32.0.Final) in a java project where I have as a decision table an xls file where base on some condition to return the data from that xls. After I created the POJO object with some data and insert in the engine the field where I expect to be set is null.

The code to create a KieSession is:

KieFileSystem kieFileSystem = kieServices.newKieFileSystem();
kieFileSystem.write(ResourceFactory.newClassPathResource("path to the xls file"));
KieBuilder kb = kieServices.newKieBuilder(kieFileSystem);
kb.buildAll();
KieModule kieModule = kb.getKieModule();
KieContainer kContainer = kieServices.newKieContainer(kieModule.getReleaseId());
kContainer.newKieSession();

I tried also providing a Resource but same result:

KieFileSystem kieFileSystem = kieServices.newKieFileSystem().write(dt);
KieBuilder kieBuilder = kieServices.newKieBuilder(kieFileSystem).buildAll();
KieModule kieModule = kieBuilder.getKieModule();
KieContainer kContainer = kieServices.newKieContainer(kieModule.getReleaseId());
kContainer.newKieSession();

Decision table looks like this: First line contains a rule set. Second line contains import object model followed by RuleTabel with the specification.

NOTE: If I tried to convert the xls to drl, it is converted correctly.

Specification: JAVA 17 kie-ci, drools-decisiontables, drools-core, drools-compiler version 8.32.0.Final

I expected that after I run this on an object to set a specific field on the input object.

kieSession.insert(depositRequest);
kieSession.fireAllRules();
kieSession.dispose();

But the expected fields were null.

Could you please anyone help me with this?

Thank you very much!


Solution

  • Likely, you missed to have a file name ending with .drl.xls, .drl.xlsx, or .drl.csv.

    Tested with: https://github.com/tarilabs/demo-so75716587

    and that works for me.

    We're adding explitic mention in the documentation as we speak.