0

I'm having some problems including Apache Poi in a simple Jira plugin. While trying to make a simple proof of concept to generate an Excel file (ooxml actually) I'm getting some dependency / class cast exception issues. My plugin extends AbstractSearchRequestView and the following code snippets tries to output an empty xlsx file.

  public void writeSearchResults(SearchRequest sr, SearchRequestParams srp, Writer writer) throws SearchException
  {
    XSSFWorkbook wb = new XSSFWorkbook();
    WriterOutputStream out = new WriterOutputStream(writer);
    wb.write(out);
  }

Now I have my export option available in the Jira issue search screen, but when running it I'm getting the following classcastexception:

java.lang.ClassCastException: com.ctc.wstx.stax.WstxEventFactory cannot be cast to javax.xml.stream.XMLEventFactory

My pom file POI dependencies look like this:

<dependency>
  <groupId>org.apache.poi</groupId>
  <artifactId>poi</artifactId>
  <version>3.15</version>
</dependency>
<dependency>
  <groupId>org.apache.poi</groupId>
  <artifactId>poi-ooxml</artifactId>
  <version>3.15</version>
</dependency>

I have tried to configure everything like in this question / answer but I get the same issue.

Community
  • 1
  • 1
Robe Elckers
  • 967
  • 1
  • 6
  • 19

1 Answers1

0

Try with below set of dependencies.

        <dependency>
            <groupId>org.apache.xmlbeans</groupId>
            <artifactId>xmlbeans</artifactId>
            <version>2.6.0</version>
            <exclusions>
                <exclusion>
                    <groupId>stax</groupId>
                    <artifactId>stax-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.14</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.14</version>
            <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>
        </dependency>
MrKumar
  • 476
  • 3
  • 10