0

I have a Tomcat application that writes out spreadsheets and it was using the following JAR files:

  • poi-3.16.jar
  • poi-ooxml-3.16.jar
  • poi-ooxml-schemas-3.16.jar

I saw there was a version 4.0.1 of poi, and in looking at https://poi.apache.org/components/ I think I have the prerequisites set up, but I get an Exception when running:

25-Mar-2019 22:33:37.117 SEVERE [http-nio-8181-exec-10] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [xxx.ApplicationConfig] in context with path [/DataLoaderREST] threw exception [org.glassfish.jersey.server.ContainerException: java.lang.ExceptionInInitializerError] with root cause
 java.lang.RuntimeException: Uncompilable source code - cannot find symbol
  symbol:   class POIXMLDocument
  location: package org.apache.poi

Update:

Apparently when I built my .WAR file that gave the above error, it looks like NetBeans found the old 3.16 jar files and compiled my code, but I didn't have the 3.16 jar files on the server. Now that I've done a clean in NetBeans, I cannot compile in NetBeans.

Error:

--- maven-compiler-plugin:2.3.2:compile (default-compile) @ DataModules ---
Compiling 44 source files to C:\xxx\xxx\10 Software\Java\LoaderFramework\DataModules\target\classes
-------------------------------------------------------------
COMPILATION ERROR : 
-------------------------------------------------------------
com/xxx/billing/loader/parser/ExcelParser.java:[36,21] error: cannot find symbol

And ExcelParser.jara line 36 is:

import org.apache.poi.POIXMLDocument;

Here is my pom.xml, referencing the 4.0.1 jars:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.xx.billing</groupId>
    <artifactId>DataModules</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
    </properties>

        <dependencies>
               <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>18.0</version>
        </dependency>

        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.11.0</version>
        </dependency>

        <!-- POI artifacts See https://poi.apache.org/components/  -->
        <dependency>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
                <version>1.2</version>
        </dependency>
        <dependency>
          <groupId>commons-codec</groupId>
          <artifactId>commons-codec</artifactId>
          <version>1.11</version>
        </dependency>
        <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-collections4</artifactId>
                <version>4.2</version>
        </dependency>
        <dependency>
          <groupId>org.apache.commons</groupId>
          <artifactId>commons-math3</artifactId>
          <version>3.6.1</version>
        </dependency>
        <dependency>
          <groupId>log4j</groupId>
          <artifactId>log4j</artifactId>
          <version>1.2.17</version>
          <!-- type>bundle</type -->
        </dependency>

        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>4.0.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml-schemas</artifactId>
            <version>4.0.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>org.apache.commons</groupId>
          <artifactId>commons-compress</artifactId>
          <version>1.18</version>
        </dependency>        
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>4.0.1</version>
            <type>jar</type>
        </dependency>

        <dependency>
            <groupId>com.xx.billing</groupId>
            <artifactId>DataLoderShared</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>     

        <dependency>
            <groupId>com.rabbitmq</groupId>
            <artifactId>amqp-client</artifactId>
            <version>3.5.4</version>
            <scope>compile</scope>
        </dependency>   
        <dependency>
            <groupId>com.univocity</groupId>
            <artifactId>univocity-parsers</artifactId>
            <version>1.5.6</version>
            <scope>compile</scope>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>com.ibm.icu</groupId>
            <artifactId>icu4j</artifactId>
            <version>55.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-core</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

</project>

I have checked my NetBeans .m2 repository, and I have both 3.16 and 4.0.1 directories inC:\Users\mstewart\.m2\repository\org\apache\poi\poi\ and poi\ooxml and poi\ooxml-schemas

Mark Stewart
  • 2,046
  • 4
  • 22
  • 32
  • 2
    [org.apache.poi.ooxml.POIXMLDocument](https://poi.apache.org/apidocs/dev/org/apache/poi/ooxml/POIXMLDocument.html); [package org.apache.poi.ooxml](https://svn.apache.org/viewvc/poi/tags/REL_4_0_1/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocument.java?view=markup) – Axel Richter Mar 26 '19 at 04:36
  • @Axel Hmmmm. I do see it in that jar file; and I thought I have that jar file deployed; I'll need to see if I have it in the right directory. – Mark Stewart Mar 26 '19 at 14:26
  • Added info on my pom.xml and details on original error and now error in compiling – Mark Stewart Mar 26 '19 at 16:37

1 Answers1

1

I stared at the compiler error

import org.apache.poi.POIXMLDocument;

for days, and just noticed it was missing the ooxml part of the package; changed it to

import org.apache.poi.ooxml.POIXMLDocument;

And all is well. Thanks Axel for the links; that helped me eventually find the issue.

Mark Stewart
  • 2,046
  • 4
  • 22
  • 32