Apache POI,Excel 2007+ XML和OSGI [英] Apache POI, Excel 2007+ XML, and OSGI
问题描述
对于一个项目,我正在尝试使用Apache POI与OSGI一起使用Excel XML功能.
For a project I'm trying to get Excel XML functionality using Apache POI to work with OSGI.
我已经尝试过POI ServiceMix捆绑软件,但这缺少了ooxml-schemas jar.将罐子添加到捆绑包中并将其包含在清单中似乎没有用.
I've tried the POI ServiceMix bundle, but this was missing the ooxml-schemas jar. Adding the jar to the bundle and including it in the manifest didn't seem to work.
然后,我尝试为POI 3.10创建包装器束,但无济于事.同样的错误.
Then I tried to creating wrapper bundles for POI 3.10, but also to no avail. Same error.
Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl not found by org.apache.poi [8]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
... 105 more
随后的调用导致以下结果:
Subsequent calls lead to the following:
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument
at org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument$Factory.parse(Unknown Source)
at org.apache.poi.xssf.model.ThemesTable.<init>(ThemesTable.java:44)
... 93 more
XMLBeans可作为捆绑包导出所有包,我已经尝试了ServiceMix捆绑包,并从POI 3.10附带的jar中制作了一个.
XMLBeans is available as a bundle exporting all of its packages, and I've tried the ServiceMix bundle as well as making one out of the jar included with POI 3.10.
有人可以指导我完成创建可以处理Excel 2007+ XML文档的OSGI捆绑包的过程吗?非常感谢.
Could someone guide me through the process of creating a working OSGI bundle that can handle Excel 2007+ XML documents? Help much appreciated.
推荐答案
问题是org.apache.poi.ooxml-schemas
中的类调用Class.forName("org.apache.xmlbeans.impl.schema")
,因此您需要在ooxml-schemas软件包的清单中导入此软件包.
The problem is that the classes from org.apache.poi.ooxml-schemas
call Class.forName("org.apache.xmlbeans.impl.schema")
, so you need an import of this package in the manifest of your ooxml-schemas bundle.
在构建ooxml-schemas捆绑包时,我通过在maven-bundle-plugin
的配置中添加<DynamicImport-Package>*</DynamicImport-Package>
来解决该问题.
I solved it by adding <DynamicImport-Package>*</DynamicImport-Package>
to the configuration of the maven-bundle-plugin
when building the ooxml-schemas bundle.
这篇关于Apache POI,Excel 2007+ XML和OSGI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!