0

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]
vinS
  • 1,417
  • 5
  • 24
  • 37
Arun
  • 131
  • 1
  • 4
  • 15
  • It seems like you have multiple versions of same class in your classpath, perhaps. – muasif80 Dec 11 '17 at 12:31
  • Why are you using an old version of Apache POI? What happens if you just grab the latest Apache Servicemix bundle of POI? – Gagravarr Dec 11 '17 at 18:33

1 Answers1

0

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>
Renato Barros
  • 177
  • 3
  • 14
  • In my case, I have bundles that are already using pure POI. So that I can't move to servicemix now. – Arun Dec 12 '17 at 12:54
  • Did you import the packages from POI into your Manifest? You need to import then or use Dynamic Import, like: * – Renato Barros Dec 12 '17 at 13:00