0
votes

I am trying to read Excel using Apache POI which is deployed as bundle in Karaf.

Used POI versions as per order:

  • poi-3.11.jar
  • poi-ooxml-3.11.jar
  • poi-ooxml-schemas-3.11.jar

feature.xml snippet(For wrapping the bundles in 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(dependency 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>

Above jars used as dependency in project as well as bundles in Karaf.

Tried servicemix version of POI. But it also doesn't help.

I understand NoClassDefFoundError is runtime error, which is caused while the class is not found at runtime. Please give me resolution for this issue.

Stack Trace:

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]
1
It seems like you have multiple versions of same class in your classpath, perhaps.muasif80
Why are you using an old version of Apache POI? What happens if you just grab the latest Apache Servicemix bundle of POI?Gagravarr

1 Answers

0
votes

I've worked in a project that uses servicemix bundle rather directly POI.

<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi/3.15_1</bundle>