java.lang.NoClassDefFoundError: org/apache/poi/hss

2019-05-28 00:51发布

问题:

java.lang.NoClassDefFoundError:org/apache/poi/hssf/usermodel/HSSFWorkbook

This is java web project. The java project is ok, but in web, I got this exception.

Caused by: java.lang.ClassNotFoundException: org.apache.poi.hssf.usermodel.HSSFWorkbook
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)

maven dependency :

<!-- apahce poi -->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.7</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-scratchpad</artifactId>
        <version>3.7</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.7</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml-schemas</artifactId>
        <version>3.7</version>
    </dependency>

回答1:

You need to put the Apache POI files in the WEB-INF/lib folder on the server.



回答2:

Check .m2 directory and try to find class HSSFWorkbook if this class is present, check lib folder of your web app and try to find the same.



回答3:

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