【发布时间】:2014-08-20 10:48:34
【问题描述】:
我正在编写一个将数据导出到 Excel 工作表的应用程序。
我不会使用 XSSFWorkbook 类,因为我的 Excel 超出了 HSSFWorkbook 类的 255 列的限制。
我下载了 Apache POI 库,并将以下库包含到我的项目中: - 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 中,所以我认为这不是我的问题。
谁能帮帮我?谢谢。
【问题讨论】:
-
你确定你的类路径中没有任何旧的 xmlbeans 或 poi jars 吗?
-
至少不是xmlbeans的名字。
-
如果您尝试按照this POI FAQ entry 将
poi-ooxml-schemasjar 切换为完整的ooxml-schemas-1.1jar,会发生什么? -
谢谢,但我尝试使用 ooxml-schemas-1.1 并继续遇到同样的问题。
-
您确定您的类路径中只有一个 xmlbeans jar,并且认可的 jar 或安全管理器或其他任何东西都没有什么好笑的吗?相同的 jar 组合在数千台机器上运行良好......
标签: java apache-poi xmlbeans