The issue is with your log4j jars. They are not matching up with each
other.POI 5.2.3 defaults to log4j-api 2.18.0.
There are a lot of things that go wrong with deploying logging jars and I think
you would be better off reading the log4j docs and checking stackoverflow.com
for details about how to set up log4j logging in Tomcat.
Tomcat might have a different version of log4j and you might need to do some
configuration of your web.xml deployment descriptor - again best to ask a
Tomcat expert about that.
On Monday 31 October 2022 at 16:49:48 GMT, Campbell, Lance
<[email protected]> wrote:
I just started working with POI. . I am just writing out an Excel document. I
pulled down the project using Maven for 5.2.3 .
In eclipse everything compiled fine. When I deployed the software to Tomcat I
got this error message:
Exception in thread "Thread-6" java.lang.NoSuchMethodError:
org.apache.logging.log4j.util.LoaderUtil.getClassLoaders()[Ljava/lang/ClassLoader;
The line it was failing on is the last line listed below "new XSSFWorkbook()":
XSSFWorkbook workbook = null;
//
ClassLoader classloader =
org.apache.poi.poifs.filesystem.POIFSFileSystem.class.getClassLoader();
URL res =
classloader.getResource("org/apache/poi/xssf/usermodel/XSSFWorkbook.class");
String path = res.getPath();
System.out.println("POI Core came from " + path);
//
// line with error is below
workbook = new XSSFWorkbook();
After reading some documentation I put in the code directly above the line that
was failing. The display showed that the code was found.
POI Core came from
file:/folder1/folder2/folder3/application/webapps/ROOT/WEB-INF/lib/poi-ooxml-5.2.2.jar!/org/apache/poi/xssf/usermodel/XSSFWorkbook.class
I tried rebuilding the project in Eclipse and also updating Maven. After
redeploying I kept getting the same error message.
I then changed the version to 5.2.2 and everything worked fine. I am wondering
if there might be an issue with 5.2.3 .
MAVEN that did NOT work:
<dependencies>
<dependency>
<groupId>webserviceslib</groupId>
<artifactId>webserviceslib</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.3</version>
</dependency>
</dependencies>
MAVEN that does work:
<dependencies>
<dependency>
<groupId>webserviceslib</groupId>
<artifactId>webserviceslib</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.2</version>
</dependency>
</dependencies>
Thanks,
Lance Campbell
Web Services @ Public Affairs @ University of Illinois