Hello,
the exception is the following:
java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.poi.xssf.eventusermodel.XSSFReader.<init>(Lorg/apache/poi/openxml4j/opc/OPCPackage;)V" the class loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoader) of the current class, com/...., and the class loader (instance of org/apache/catalina/loader/ParallelWebappClassLoader) for the method's defining class, org/apache/poi/xssf/eventusermodel/XSSFReader, have different Class objects for the type org/apache/poi/openxml4j/opc/OPCPackage used in the signature
We have a support plugin, the pom.xml looks like that:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.15</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.15</version>
<exclusions>
<exclusion>
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
</exclusion>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>ooxml-schemas</artifactId>
<version>1.4</version>
</dependency>
<Export-Package>
liquibase*,
org.apache.poi.*,
org.apache.fop.*,
org.openxmlformats.schemas.spreadsheetml.*
</Export-Package>
<Import-Package>
!com.sun.javadoc,
!com.sun.tools.javadoc,
!junit.framework,
!org.apache.commons.cli,
!org.apache.batik.extension.svg,
!org.apache.fontbox.cff.charset,
!org.apache.fontbox.cff.encoding,
!org.apache.jcp.xml.dsig.internal.dom,
!org.apache.log,
!org.apache.log.format,
!org.apache.log.util,
!org.apache.poi.hslf.blip,
!org.apache.poi.hsmf,
!org.apache.poi.hsmf.datatypes,
!org.apache.poi.hsmf.extractor,
!org.apache.poi.hwpf.extractor,
!org.apache.tools.ant,
!org.apache.tools.ant.taskdefs,
!org.apache.tools.ant.types,
!org.apache.tools.ant.types.resources,
!org.apache.tools.ant.util,
!org.apache.xml.security,
!org.apache.xml.security.c14n,
!org.apache.xml.security.utils,
!org.junit,
!org.junit.internal,
!org.junit.runner,
!org.junit.runner.notification,
*;version="0.0"
</Import-Package>
The pom.xml of the actual plugin:
<Import-Package>
...
org.apache.poi;version="0.0.0",
org.apache.poi.openxml4j.*;version="0.0.0",
*;version="0.0"
</Import-Package>
I need the XSSFReader class in order to stream-read potential large xlsx files. The exception is thrown at line:
XSSFReader r = new XSSFReader(pkg);
XSSFReader resides in the package
org.apache.poi.xssf.eventusermodel
If I try to use the ReadOnlySharedStringsTable which class also resides in the same package I get:
java.lang.NoClassDefFoundError: org/apache/poi/xssf/eventusermodel/ReadOnlySharedStringsTable
If I search for poi on my container I get these results:
/var/lib/confluence/plugins-osgi-cache/felix/felix-cache/bundle228/version0.0/OfficeConnector-7.0.8.jar-embedded/META-INF/lib/poi-scratchpad-3.5-FINAL.jar
/var/lib/confluence/plugins-osgi-cache/felix/felix-cache/bundle228/version0.0/OfficeConnector-7.0.8.jar-embedded/META-INF/lib/poi-ooxml-3.5-FINAL.jar
/var/lib/confluence/plugins-osgi-cache/felix/felix-cache/bundle228/version0.0/OfficeConnector-7.0.8.jar-embedded/META-INF/lib/poi-3.5-FINAL.jar
...
The poi version 3.5-FINAL does not include the ReadOnlySharedStringsTable class, which makes me believe that at runtime somehow this older version will be used.
Please note I can use the regular poi classes (XSSFWorkbook, SXSSFWorkbook...) without any problems.