xmlbeans could not locate schema resource when rep

2019-07-30 04:30发布

问题:

I am writing an application that needs to be contained in a jar.

The program needs to validate and grab data from an excel spreadsheet. Therefore I am using the Apache POI libraries which are dependent on xmlbeans jar.

My problem is that when I include the xmlbeans jar in my jar using ant

<jar 
...
<zipfileset src="${xmlbeans.jar}" includes="**/*" />

Build and then run the jar, I get the following error:

Caused by: org.apache.xmlbeans.SchemaTypeLoaderException: XML-BEANS compiled schema: Could not locate compiled schema resource schemaorg_apache_xmlbeans/system/sE130CAA0A01A7CDE5A2B4FEB8B311707/index.xsb (schemaorg_apache_xmlbeans.system.sE130CAA0A01A7CDE5A2B4FEB8B311707.index) - code 0
at org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl$XsbReader.<init>(SchemaTypeSystemImpl.java:1519)
at org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.initFromHeader(SchemaTypeSystemImpl.java:273)
at org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.<init>(SchemaTypeSystemImpl.java:185)

When unit testing with testng this works fine. So the problem obviously lies with incorporating the xmlbeans jar into my jar. Is it possible to do this? POI libraries are dependent on it.

I have uncompressed my jar, and indeed the resource is missing.

I am using the correct version of xmlbeans for the poi libraries I am using.

Here are the libraries I am using:

poi-3.7.jar poi-ooxml-3.7-beta3.jar poi-ooxml-schemas-3.7-beta3.jar

and the following version of xmlbeans:

xmlbeans-2.3.0.jar

Many thanks