1

I've searched along foruns and even though there's a lot of issues regarding this same error, none of them actually helped me with solving this error.

I'm getting this error:

org.apache.cxf.interceptor.Fault: org/apache/poi/xssf/usermodel/XSSFWorkbook
    at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162)
    at [internal classes]
Caused by: java.lang.NoClassDefFoundError: org/apache/poi/xssf/usermodel/XSSFWorkbook
    at com.test.GetFromExcel.readXLSX(GetFromExcel.java:25)
    ... 1 more

[ERROR   ] SRVE0315E: Ocorreu uma exceção: java.lang.Throwable: org.apache.cxf.interceptor.Fault: org/apache/poi/xssf/usermodel/XSSFWorkbook
    at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:4998)

I've tried removing .m2 folder and downloading dependencies again, still not a successfull atempt. I've added the .jar files, as you can see in the image.

enter image description here

And I can see that same class the error is complaining about listed right where the path indicates in org/apache/poi/xssf/usermodel/XSSFWorkbook .

enter image description here

Not clear to me why the error is frequent if I can see the class in my project.

Project's pom.xml as requested.

Thing is I have 2 other projects where I use this library and they both never gave me any headache like this to make POI library works. I used the same configuration I used previously in those projects.

<?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>

    <parent>
        <groupId>net.wasdev.maven.parent</groupId>
        <artifactId>java8-parent</artifactId>
        <version>1.4</version>
        <relativePath></relativePath>
    </parent>

    <groupId>net.wasdev.wlp.sample</groupId>
    <artifactId>my-project</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>MYPROJECT</name>
    <url>http://google.com</url>

    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>https://raw.github.com/WASdev/sample.servlet/master/LICENSE</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.apache.geronimo.specs</groupId>
                <artifactId>geronimo-servlet_3.0_spec</artifactId>
                <version>1.0</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/net.wasdev.maven.tools.targets/liberty-apis -->
        <dependency>
            <groupId>net.wasdev.maven.tools.targets</groupId>
            <artifactId>liberty-apis</artifactId>
            <version>17.0.0.2</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.0</version>
        </dependency>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>javax.mail-api</artifactId>
            <version>1.5.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-servlet_3.0_spec</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>com.cloudant</groupId>
            <artifactId>cloudant-client</artifactId>
            <version>2.12.0</version>
        </dependency>
        <!-- lib local -->
        <dependency>
            <groupId>com.ibm.db2.jcc</groupId>
            <artifactId>db2jcc</artifactId>
            <version>3.1</version>
            <scope>system</scope>
            <systemPath>${basedir}/libs/db2jcc.jar</systemPath>
        </dependency>

        <dependency>
            <groupId>org.xerial</groupId>
            <artifactId>sqlite-jdbc</artifactId>
            <version>3.8.11.2</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <version>2.22.2</version>
            <scope>test</scope>
        </dependency>

        <!-- PropertyUtils -->
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.8.3</version>
        </dependency>
        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path</artifactId>
            <version>2.0.0</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.9.2</version>
        </dependency>

        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-s3</artifactId>
            <version>1.11.425</version>
        </dependency>
        <dependency>
            <groupId>com.ibm.cos</groupId>
            <artifactId>ibm-cos-java-sdk</artifactId>
            <version>2.4.2</version>
        </dependency>

        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.13</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>ooxml-schemas</artifactId>
            <version>1.1</version>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>

            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <configuration>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                        <warName>bms-code-management</warName>
                        <webXml>src/main/web.xml</webXml>
                        <warSourceDirectory>front/dist</warSourceDirectory>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>net.wasdev.wlp.maven.plugins</groupId>
                    <artifactId>liberty-maven-plugin</artifactId>
                    <version>1.2.1</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>net.wasdev.wlp.maven.plugins</groupId>
                <artifactId>liberty-maven-plugin</artifactId>
                <configuration>
                    <configFile>src/main/wlp/server.xml</configFile>
                    <bootstrapProperties>
                        <appLocation>../../../../../${project.build.finalName}</appLocation>
                    </bootstrapProperties>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.2</version>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/server</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>server</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <reporting>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.7</version>

                <configuration>
                    <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
                </configuration>
            </plugin>

        </plugins>
    </reporting>
</project>
Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
lsilva
  • 147
  • 2
  • 17
  • i think this is related [java.lang.NoClassDefFoundError: org/apache/poi/xssf/usermodel/XSSFWorkbook](https://stackoverflow.com/questions/44193879/java-lang-noclassdeffounderror-org-apache-poi-xssf-usermodel-xssfworkbook) – Tanmoy Majumdar Jun 12 '20 at 21:10
  • Two suggestions: what's your pom.xml? have you tried with POI 3.17 (or even 4.1.2) – bsaverino Jun 12 '20 at 21:21
  • @bsaverino, tried with 3.17 and same error. – lsilva Jun 15 '20 at 18:22
  • Thanks, can you show your pom.xml and tell us which jvm version you have? – bsaverino Jun 15 '20 at 20:19
  • @bsaverino, updated question with pom.xml as you requested – lsilva Jun 15 '20 at 20:42
  • I cannot reproduce here. Is it possible that your other project(s) that are using Apache CXF make use of POI but do not have access to the classes at runtime? I mean you are showing an org.apache.cxf.interceptor Fault and no CXF lib is present in the given pom. I'd suspect naively a runtime dependency not met in your other project. – bsaverino Jun 15 '20 at 21:30

1 Answers1

0

In my case I had to add the following dependencies in my pom.xml

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>5.2.0</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>5.2.0</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>javax.xml.stream</groupId>
        <artifactId>stax-api</artifactId>
        <version>1.0-2</version>
    </dependency>
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.11.0</version>
    </dependency>

All those 4 libs with exact versions, including stax-api. It should be noted that I use Maven.

Hope it'll help someone (I literally spent hours to fix this problem).

Vnuuk
  • 6,177
  • 12
  • 40
  • 53