[rules-dev] Exception with Drools-XLS and Maven: "An error occured opening the workbook."

Geoffrey De Smet ge0ffrey.spam at gmail.com
Tue Aug 11 14:22:03 EDT 2009


By default the maven resources plugin copies resources in the encoding 
of the platform it's build on IRCC.
It's better to lock that down on UTF-8.
It even logs a warning if it's not locked down.
Is that xls file a resource that's being copied?

With kind regards,
Geoffrey De Smet


Bernd Rücker schreef:
> Hi all.
> 
>  
> 
> I recently had the same exception as reported in 
> https://jira.jboss.org/jira/browse/GUVNOR-286, but didn’t find anything 
> on the web. We currently have the same error with Maven and Drools 
> 5.0.1, very strange:
> 
>  
> 
> Testcode
> 
>  
> 
>     public static void main(String[] args) {
> 
>            final DecisionTableConfiguration dtableconfiguration = 
> KnowledgeBuilderFactory.newDecisionTableConfiguration();
> 
>             dtableconfiguration.setInputType( DecisionTableInputType.XLS );
> 
>  
> 
>             final KnowledgeBuilder kbuilder = 
> KnowledgeBuilderFactory.newKnowledgeBuilder();
> 
>             kbuilder.add(  
> ResourceFactory.newClassPathResource("Sample.xls", Test.class ),
> 
>                                   ResourceType.DTABLE,
> 
>                                   dtableconfiguration );
> 
>  
> 
>             final KnowledgeBase kbase = 
> KnowledgeBaseFactory.newKnowledgeBase();
> 
>             kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
> 
>  
> 
>             // typical decision tables are used statelessly
> 
>             StatefulKnowledgeSession ksession = 
> kbase.newStatefulKnowledgeSession();       
> 
>     }
> 
>  
> 
> Stacktrace:
> 
>  
> 
> org.drools.template.parser.DecisionTableParseException: An error occured 
> 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:89)
> 
>     at 
> org.drools.decisiontable.SpreadsheetCompiler.compile(SpreadsheetCompiler.java:90)
> 
>     at 
> org.drools.decisiontable.SpreadsheetCompiler.compile(SpreadsheetCompiler.java:69)
> 
>     at 
> org.drools.decisiontable.DecisionTableProviderImpl.compileStream(DecisionTableProviderImpl.java:29)
> 
>     at 
> org.drools.decisiontable.DecisionTableProviderImpl.loadFromInputStream(DecisionTableProviderImpl.java:19)
> 
>     at 
> org.drools.compiler.DecisionTableFactory.loadFromInputStream(DecisionTableFactory.java:16)
> 
>     at 
> org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:508)
> 
>     at 
> org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:31)
> 
>     at Test.main(Test.java:21)
> 
> Caused by: jxl.read.biff.BiffException: Unable to recognize OLE stream
> 
>     at jxl.read.biff.CompoundFile.<init>(CompoundFile.java:111)
> 
>     at jxl.read.biff.File.<init>(File.java:113)
> 
>     at jxl.Workbook.getWorkbook(Workbook.java:250)
> 
>     at jxl.Workbook.getWorkbook(Workbook.java:235)
> 
>     at 
> org.drools.decisiontable.parser.xls.ExcelParser.parseFile(ExcelParser.java:74)
> 
>     ... 8 more
> 
>  
> 
> The strange thing: When we tried it with Eclipse (3.4.2) and created a 
> Drools project, everything worked. When we created a maven project and 
> added exactly the same libraries, the exception was caused.
> 
>  
> 
> We tracked it down to the .project file:
> 
>  
> 
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <projectDescription>
> 
>     <name>iks_drools</name>
> 
>     <comment></comment>
> 
>     <projects>
> 
>     </projects>
> 
>     <buildSpec>
> 
>         <buildCommand>
> 
>             <name>org.eclipse.jdt.core.javabuilder</name>
> 
>             <arguments>
> 
>             </arguments>
> 
>         </buildCommand>
> 
>         <!-- buildCommand>
> 
>             <name>org.maven.ide.eclipse.maven2Builder</name>
> 
>             <arguments>
> 
>             </arguments>
> 
>         </buildCommand -->
> 
>         <buildCommand>
> 
>             <name>org.drools.eclipse.droolsbuilder</name>
> 
>             <arguments>
> 
>             </arguments>
> 
>         </buildCommand>
> 
>     </buildSpec>
> 
>     <natures>
> 
>         <nature>org.eclipse.jdt.core.javanature</nature>
> 
>         <!-- nature>org.maven.ide.eclipse.maven2Nature</nature -->
> 
>     </natures>
> 
> </projectDescription>
> 
>  
> 
> With the comments it works, without the comments and the maven2Builder 
> and natures it causes the exception. We are puzzled.
> 
>  
> 
> Any ideas?
> 
>  
> 
> Hopefully it is OK to post that to the dev lists, seems a pretty deep thing…
> 
> 
> Thanks a lot and Cheers
> 
> Bernd
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> rules-dev mailing list
> rules-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev



More information about the rules-dev mailing list