Получение приведенного ниже фрагмента кода, который я использую для чтения таблицы решений xls для создания KieSession.
public KieSession ASRVariantDtSession() {
KieFileSystem kieFileSystem = kieServices.newKieFileSystem();
Resource dt = ResourceFactory.newClassPathResource("rules/ASRSelectVariant.xls",getClass());
kieFileSystem.write(dt);
KieBuilder kb = kieServices.newKieBuilder(kieFileSystem);
kb.buildAll();
KieModule kieModule = kb.getKieModule();
KieContainer kContainer = kieServices.newKieContainer(kieModule.getReleaseId());
return kContainer.newKieSession();
}
Используемые зависимости: Drools 7.33.0Последние зависимости
Но получение ниже ошибки при чтении xls Таблица решений из пути к классу ресурсов все время.
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)
at org.drools.decisiontable.SpreadsheetCompiler.parseResource(SpreadsheetCompiler.java:136)
at org.drools.decisiontable.SpreadsheetCompiler.compile(SpreadsheetCompiler.java:120)
at org.drools.decisiontable.SpreadsheetCompiler.compile(SpreadsheetCompiler.java:93)
at org.drools.decisiontable.DecisionTableProviderImpl.compileResource(DecisionTableProviderImpl.java:74)
at org.drools.decisiontable.DecisionTableProviderImpl.loadFromResource(DecisionTableProviderImpl.java:42)
at org.drools.compiler.compiler.DecisionTableFactory.loadFromResource(DecisionTableFactory.java:36)
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.decisionTableToPackageDescr(KnowledgeBuilderImpl.java:402)
at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl$ResourceToPkgDescrMapper.lambda$static$4(CompositeKnowledgeBuilderImpl.java:326)
at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildResource(CompositeKnowledgeBuilderImpl.java:198)
at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildPackageDescr(CompositeKnowledgeBuilderImpl.java:185)
at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:106)
at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:98)
at org.drools.compiler.kie.builder.impl.AbstractKieProject.buildKnowledgePackages(AbstractKieProject.java:261)
at org.drools.compiler.kie.builder.impl.AbstractKieProject.verify(AbstractKieProject.java:75)
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildKieProject(KieBuilderImpl.java:274)
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:242)
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:192)
at com.dlh.lhopenapi.testdts.drools.DroolsConfiguration.ASRVariantDtSession(DroolsConfiguration.java:58)
at com.dlh.lhopenapi.testdts.service.TestDtsService.executeASRVariantRules(TestDtsService.java:98)
at com.dlh.lhopenapi.testdts.service.TestDtsService.access$1(TestDtsService.java:97)
at com.dlh.lhopenapi.testdts.service.TestDtsService$PeriodicCheckForTriggerEvents.run(TestDtsService.java:72)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.poi.openxml4j.exceptions.InvalidFormatException: Your InputStream was neither an OLE2 stream, nor an OOXML stream
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:186)
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:149)
at org.drools.decisiontable.parser.xls.ExcelParser.parseFile(ExcelParser.java:85)
... 28 common frames omitted
Пожалуйста, помогите мне решить эту проблему.
Примечание. Из внешнего расположения файла (файл xls вне проекта) это работает должным образом .