XML-BEANS compiled schema: Could not locate compiled schema resource schemaorg_apache_xmlbeans/system/sE130CAA0A01A7CDE5A2B4FEB8B311707/index.xsb

mai87 picture mai87 · Aug 20, 2014 · Viewed 7.4k times · Source

I am writing an aplication to export data to an Excel sheet.

I wont to use the XSSFWorkbook class because my Excel exceeds the limit of 255 column of HSSFWorkbook class.

I downloaded the Apache POI libraries and I included the folowing libraries to my proyect: - poi-3.9.jar - poi-excelant-3.9.jar - poi-ooxml-3.9.jar - poi-ooxml-schemas-3.9.jar - poi-scratchpad-3.9.jar - dom4j-1.6.1.jar - stax-api-1.0.1.jar - xmlbeans-2.3.0.jar

When I export the data to get the Excel sheet I get this runtime error:

java.lang.ExceptionInInitializerError
    at sun.misc.Unsafe.ensureClassInitialized(Native Method)
    at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
    at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
    at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
    at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
    Truncated. see log file for complete stacktrace
Caused By: java.lang.RuntimeException: Could not instantiate SchemaTypeSystemImpl (java.lang.reflect.InvocationTargetException): is the version of xbean.jar correct?
    at schemaorg_apache_xmlbeans.system.sE130CAA0A01A7CDE5A2B4FEB8B311707.TypeSystemHolder.loadTypeSystem(Unknown Source)
    at schemaorg_apache_xmlbeans.system.sE130CAA0A01A7CDE5A2B4FEB8B311707.TypeSystemHolder.<clinit>(Unknown Source)
    at sun.misc.Unsafe.ensureClassInitialized(Native Method)
    at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
    at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
    Truncated. see log file for complete stacktrace
Caused By: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at schemaorg_apache_xmlbeans.system.sE130CAA0A01A7CDE5A2B4FEB8B311707.TypeSystemHolder.loadTypeSystem(Unknown Source)
    Truncated. see log file for complete stacktrace
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)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    Truncated. see log file for complete stacktrace

I read in a post that cant be because of the version of xbean-xx.jar and I notice that I don't have this library, I included in my project the version xbean-2.3.jar and has not change anything.

I read in another post of stackoverflow other solution: xmlbeans could not locate schema resource when repacking xml beans jar into my own jar . I don't know if I understood the solution correctly but the file /schemaorg_apache_xmlbeans/system/sE130CAA0A01A7CDE5A2B4FEB8B311707/index.xsb is in the jar poi-ooxml-schemas-3.9.jar so I figured that this is not my problem.

Can anyone help me please? thanks.

Answer

Gagravarr picture Gagravarr · Aug 21, 2014

I've spotted your problem

The key line of the exception is this:

XML-BEANS compiled schema: Could not locate compiled schema resource schemaorg_apache_xmlbeans/system/sE130CAA0A01A7CDE5A2B4FEB8B311707/index.xsb 

Next up, we see your rather non-standard way of including all the jars (which isn't usually recommended, including for reasons like this), and we see these lines:

<zipfileset src="../lib/poi-ooxml-3.10-FINAL-20140208.jar" includes="**/*.class, **/*.properties, **/*.txt" />
<zipfileset src="../lib/ooxml-schemas-1.1.jar" includes="**/*.class, **/*.properties" />

You are explicitly only pulling in certain kinds of files, and excluding all others from those jars. Look at the extension of the missing file in the exception - .xsb. Look at your explicit include list. See what you've missed?

You should either re-visit your whole way of building jars to pick something more "normal", or make sure you actually include all the relevant parts of the jars you're inlining, such as the .xsb files that the exception states you need