I am getting a class loading error when trying to use Apache POI in my JIRA plugin
I am currently developing a JIRA plugin that needs to produce Excel documents through Apache POI. However, when attempting to execute my code, I encounter the following error:
java.lang.NoClassDefFoundError: Could not initialize class org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller
The Maven dependencies I am utilizing are as follows:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.15</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.15</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.15</version>
<scope>compile</scope>
</dependency>
The error occurs when I attempt to create a new workbook like so:
SXSSFWorkbook workbook = new SXSSFWorkbook();
Map<String, CellStyle> cellStyles = generateCellStyles(workbook);
I also experimented with an older version (3.11), which resulted in a different error regarding XMLEventFactory. According to the stack trace, the issue arises from my servlet while handling the request. Has anyone else faced this problem? What might be causing these class loading issues in JIRA?
This is a classic OSGi classloading conflict in JIRA’s plugin framework. The NoClassDefFoundError for PackagePropertiesMarshaller means your main POI classes load fine, but JIRA’s XML libraries are clashing with POI’s XML processing dependencies.
I’ve hit this before in JIRA plugin development - it’s usually version conflicts between your POI dependencies and JIRA’s built-in XML libraries. JIRA ships with its own XML processing components that mess with POI’s internal XML handling.
Try isolating the POI dependencies using the directive in your atlassian-plugin.xml to explicitly import what you need. Or if your requirements allow it, just generate CSV files instead of Excel - way less headache. JIRA’s XML processing stack doesn’t play nice with heavy XML dependencies like POI.
check your jira version first - newer versions ship with different xml libraries that completely break poi. I switched to poi-scratchpad 3.17 and explicitly added stax-api as a dependency, which fixed the marshaller issue. also set provided for any xml-apis dependencies since jira already loads those. the sxssf workbook creation is failing because of missing stax classes, not poi itself.
Had the exact same issue two years ago building a reporting plugin. JIRA’s OSGi container has strict classloading boundaries, so POI’s heavy dependency chain gets fragmented across different classloaders. I fixed it by upgrading to POI 4.1.2 and explicitly adding the commons-compress dependency. Also modified atlassian-plugin.xml to bundle POI jars directly instead of letting JIRA’s container handle them. Set any XML dependencies JIRA already includes to ‘provided’ scope. Another option: use Private-Package instruction in your plugin descriptor to isolate POI classes from JIRA’s internal libraries. This prevents XML processing conflicts that break marshaller initialization. Bottom line - make sure your plugin has its own POI stack copy without depending on JIRA’s shared libraries.