JIRA plugin v2 Apache POI XMLEventFactory: Provider com.ctc.wstx.stax.WstxEventFactory not found


I've added the Apache POI dependency to my JIRA plugin in order to add the ability to create Excel spreadsheets.

I've been able to create a simple spreadsheet with data populated in cells using the HSSFWorkbook.  But when I change my code to use the XSSFWorkbook (instead of HSSFWorkbook, all other code unchanged), then I'm getting the following run-time error:

java.util.ServiceConfigurationError: javax.xml.stream.XMLEventFactory: Provider com.ctc.wstx.stax.WstxEventFactory not found 
// Workbook workbook = new HSSFWorkbook(); // this works
Workbook workbook = new XSSFWorkbook(); // this gets the run-time error


Can this be some sort of jar conflict?
Here is the Apache POI dependency that I added to my pom.xml:


 I looked up the jar that has the com.ctc.wstx.stax.WstxEventFactory class and it belongs to wstx-asl-x.x.x.jar ... do I need to add a dependency to this?  Or add it to the Import-Package section?

Thanks in advance for any help!

2 answers

1 accepted

1 vote
Answer accepted

I found the solution!  I added another dependency (a jar library which contains the com.ctc.wstx.stax.WstxEventFactory class) so the following is what I needed in my pom.xml:


What fixed it for me was having following dependencies:


<!-- BE AWARE! It is absolutely crucial for wstx-asl to be bundled with plugin although it is present in Jira as well. -->
<!-- Jira version is not exported and it is a known bug: https://jira.atlassian.com/browse/JRASERVER-26214 -->
<!-- This artifact is supplemental for Apache POI library. -->

And running creation of XSSFWorkbook in different context:

XSSFWorkbook xssfWorkbook;
try {
xssfWorkbook = ContextClassLoaderSwitchingUtil.runInContext(WstxEventFactory.class.getClassLoader(), (Callable<XSSFWorkbook>) XSSFWorkbook::new);
} catch (Exception e) {
throw new IllegalStateException("Cannot create XLSX workbook with WstxEventFactory class loader.");

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Thursday in Jira

Updates to jira.atlassian.com give you visibility into what's coming in Jira Server and Data Center

Hello, Community! My name is Gosia and I'm a Product Manager on Jira Server and Data Center here at Atlassian. Since 2002 when we launched our public issue tracker, jira.atlass...

442 views 1 14
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you