kmodule with ruleTemplate fails to build with maven

154 views
Skip to first unread message

Webster Homer

unread,
Oct 17, 2018, 1:34:17 PM10/17/18
to Drools Usage
Found several problems with using the kmodule ruleTemplate
I have a rule project that had been working fine. In  the project I had a template file and a Java command to generate drl files from the template and a spreadsheet file. The command supported csv, xls, and xlsx files. The project was awkward to use. 
I had missed the fact that the kmodule had the runTemplate attribute that would allow the kmodule to take the spreadsheet and generate the drl file without having to have a command that parsed the file to generate the drl file. Great!

I edited the kmodule definition to add the ruleTemplate, referencing a csv file.

Enter code here...        <ruleTemplate dtable="rules/business/TermSearchQFRules.csv"
                  template="rules/business/templates/TermSearchQF.drt"
                  row="2" col="1"/>


ran "mvn install"

the kmodule code couldn't parse the csv file...
[ERROR] Failed to execute goal org.kie:kie-maven-plugin:7.8.0.Final:build (default-build) on project ba-search-kjar: Execution default-build of goal org.kie:kie-maven-plugin:7.8.0.Final:build failed: An error occurred opening the workbook. It is possible that the encoding of the document did not match the encoding of the reader. Your InputStream was neither an OLE2 stream, nor an OOXML stream -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.kie:kie-maven-plugin:7.8.0.Final:build (default-build) on project ba-search-kjar: Execution default-build of goal org.kie:kie-maven-plugin:7.8.0.Final:build failed: An error occurred opening the workbook. It is possible that the encoding of the document did not match the encoding of the reader.

Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-build of goal org.kie:kie-maven-plugin:7.8.0.Final:build failed: An error occurred opening the workbook. It is possible that the encoding of the document did not match the encoding of the reader.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: org.drools.template.parser.DecisionTableParseException: An error occurred opening the workbook. It is possible that the encoding of the document did not match the encoding of the reader.
at org.drools.decisiontable.parser.xls.ExcelParser.parseFile(ExcelParser.java:87)


Well that sucked...
Removed the csv file and replaced it with the .xlsx file I used to generate it.
The error changed.
[ERROR] Failed to execute goal org.kie:kie-maven-plugin:7.8.0.Final:build (default-build) on project ba-search-kjar: Execution default-build of goal org.kie:kie-maven-plugin:7.8.0.Final:build failed: No RuleTable cells in spreadsheet. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.kie:kie-maven-plugin:7.8.0.Final:build (default-build) on project ba-search-kjar: Execution default-build of goal org.kie:kie-maven-plugin:7.8.0.Final:build failed: No RuleTable cells in spreadsheet.
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-build of goal org.kie:kie-maven-plugin:7.8.0.Final:build failed: No RuleTable cells in spreadsheet.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: org.drools.template.parser.DecisionTableParseException: No RuleTable cells in spreadsheet.

I decided to revert the kmodule.xml to remove the ruleTemplate element, I again ran maven and got the same error! It seemed just having the spreadsheet file in the rules folder caused the kie plugin to try to compile it into drl files, but it cannot tell that this is a spreadsheet that uses a template.


I suspect that the problem  is with the kie maven plugin, org.kie:kie-maven-plugin  
We use the kie-maven-plugin to compile our drools projects.

I want to use the kmodule with the ruleTemplate. I'd really like it to work with csv files as we'll be keeping them in source control and would prefer to not have to store binary files
I am currently using KIE 7.8.0.Final



Webster Homer

unread,
Oct 17, 2018, 2:35:03 PM10/17/18
to Drools Usage
I found that if I remove the org.kie:kie-maven-plugin from my pom.xml file and change the packaging to jar from kjar, the kmodule creates a  jar file that can be loaded. However, if I try to use the csv file I get the org.apache.poi.openxml4j.exceptions.InvalidFormatException at run time instead of build time. So it definitely does not support csv files which is arguably a bug since templates do handle them.

I also think that the kie-maven-plugin should be able to generate the jar from the template at build time this is at least an enhancement, but again I think it's a bug. I want my errors at build time which is why I use the kie maven plugin!

Once I removed the kie-maven-plugin, and used an xlsx file, the ruleTemplate kmodule worked. Due to the two issues I found, I'm not sure that we will use this feature.

qmy...@gmail.com

unread,
Oct 31, 2018, 10:28:36 PM10/31/18
to Drools Usage
I met the same problem. Is this a bug in kie-maven-plugin. When I use 7.0.0 Final version kie-maven-plugin, it works well. But I need to update my dependency to 7.12.0 final version for the new feature. 

Is there any method to resolve this question. I read the source code and I found that plugin use the xls,xlsx as decesion table, although I have declare ruleTemplate in my kmodule.xml.

在 2018年10月18日星期四 UTC+8上午2:35:03,Webster Homer写道:
Reply all
Reply to author
Forward
0 new messages