Hi All,
We recently encountered errors related to class initialization of apache poi dependencies despite not changing the version/dependency at all since 2017. It seems that a class cannot be loaded even during Jira Software restart. We are getting error 500 from our export capabilities due to this. This is not 100% reproducible but the only time that we did reproduce the issue locally was when we tried removing dom4j.jar from this directory: \Atlassian\Jira.install4j\user. Below are some of our stack traces.
java.lang.NoClassDefFoundError: Could not initialize class org.apache.poi.openxml4j.opc.internal.marshallers.ZipPackagePropertiesMarshaller
java.lang.NoClassDefFoundError: Could not initialize class org.apache.poi.openxml4j.opc.internal.marshallers.ZipPackagePropertiesMarshaller
at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:161) [?:?]
at org.apache.poi.openxml4j.opc.OPCPackage.<init>(OPCPackage.java:141) [?:?]
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:97) [?:?]
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:324) [?:?]
java.lang.ExceptionInInitializerError
at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:161) [?:?]
at org.apache.poi.openxml4j.opc.OPCPackage.<init>(OPCPackage.java:141) [?:?]
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:97) [?:?]
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:324) [?:?]
Caused by: java.lang.ClassCastException: org.apache.xerces.stax.XMLEventFactoryImpl cannot be cast to javax.xml.stream.XMLEventFactory
at javax.xml.stream.XMLEventFactory.newInstance(XMLEventFactory.java:30) [?:1.8.0_275]
at org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.<clinit>(PackagePropertiesMarshaller.java:41) [?:?]
There are similar errors like these in other communities and below are some solutions that we have tried. These worked for others but not for our servers that encounter the issue.
- Manipulating pom.xml (Jira software is restarted every after pom changes)
Added exclusions for stax-api, xml-apis and dom4j under poi-ooxml and poi-ooxml-schemas. Also added optional tags.
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.16</version>
<scope>compile</scope>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
</exclusion>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
<exclusion>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.16</version>
<scope>compile</scope>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
</exclusion>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
<exclusion>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>ooxml-schemas</artifactId>
<version>1.3</version>
<optional>true</optional>
</dependency>
We have also removed the exclusions and optional tags in one case to test if the exclusions were causing the issue but this also did not work.
- Clearing plugin cache
Moved the .install4j folder but it did not resolve the problem.
In one of our environments, this problem only occurs in one node but not in the rest of the nodes (1 out of 4) although we expect plugins to be loaded in a similar manner when each node is restarted.
Any ideas on the matter? Thank you!