我正在尝试使用Apache POI来阅读Excel,它在Karaf中作为bundle部署。
按订单使用的POI版本:
feature.xml片段(用于包装Karaf中的包):
<bundle>wrap:mvn:org.apache.poi/poi/3.11</bundle>
<bundle>wrap:mvn:org.apache.poi/poi-ooxml/3.11</bundle>
<bundle>wrap:mvn:org.apache.poi/poi-ooxml-schemas/3.11</bundle>
pom.xml(依赖jars)
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.11<version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.11<version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.11</version>
</dependency>
以上jar用作项目中的依赖项以及Karaf
中的bundle。
尝试了servicemix
版本的POI。但它也无济于事。
我理解NoClassDefFoundError
是运行时错误,这是在运行时找不到类时引起的。请给我解决这个问题。
堆栈追踪:
java.lang.NoClassDefFoundError: org/apache/poi/POIXMLDocument
at java.lang.ClassLoader.defineClass1(Native Method)[:1.8.0_25]
at java.lang.ClassLoader.defineClass(Unknown Source)[:1.8.0_25]
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.findClass(BundleWiringImpl.java:2128)
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1432)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)
at java.lang.ClassLoader.loadClass(Unknown Source)[:1.8.0_25]
at org.apache.felix.framework.BundleWiringImpl.getClassByDelegation(BundleWiringImpl.java:1317)
at org.apache.felix.framework.BundleWiringImpl.searchImports(BundleWiringImpl.java:1481)
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1427)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)
at java.lang.ClassLoader.loadClass(Unknown Source)[:1.8.0_25]
答案 0 :(得分:0)
我曾在一个使用servicemix bundle而非直接使用POI的项目中工作过。
<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi/3.15_1</bundle>