XML-BEANS编译模式:无法找到已编译的模式资源schemaorg_apache_xmlbeans / system / sE130CAA0A01A7CDE5A2B4FEB8B311707 / index.xsb

时间:2014-08-20 10:48:34

标签: java apache-poi xmlbeans

我正在编写一个应用程序来将数据导出到Excel工作表。

我不会使用XSSFWorkbook类,因为我的Excel超出了HSSFWorkbook类的255列限制。

我下载了Apache POI库,并将以下库包含在我的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

当我导出数据以获取Excel工作表时,我收到此运行时错误:

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

我在一篇文章中读到,因为xbean-xx.jar的版本而且我注意到我没有这个库,我在项目中包含了xbean-2.3.jar版本,并没有改变任何东西

我在另一篇文章中读到了stackoverflow其他解决方案:xmlbeans could not locate schema resource when repacking xml beans jar into my own jar。我不知道我是否正确理解了解决方案,但文件/schemaorg_apache_xmlbeans/system/sE130CAA0A01A7CDE5A2B4FEB8B311707/index.xsb位于jar poi-ooxml-schemas-3.9.jar中,所以我认为这不是我的问题。

有人能帮帮我吗?谢谢。

1 个答案:

答案 0 :(得分:5)

我发现了你的问题

例外的关键是:

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

接下来,我们看到你包含所有罐子的非标准方式(通常不推荐这种方法,包括出于这样的原因),我们看到了以下几行:

<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" />

您明确只是提取某些类型的文件,并将这些文件中的所有其他文件排除在外。查看异常中遗失文件的扩展名 - .xsb。查看您的显式包含列表。看看你错过了什么?

您应该重新访问构建罐子的整个方式来选择更“正常”的东西,或者确保实际包含您正在内联的罐子的所有相关部分,例如.xsb个文件异常表明你需要