You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by "David P. Caldwell" <da...@code.davidpcaldwell.com> on 2018/11/25 12:24:19 UTC

Classpath issues with 4.0.0

I attempted to upgrade my POI installation from 3.15 to 4.0.0, but my
software now fails with a ClassNotFoundException -- specifically, it
cannot find:

java.lang.NoClassDefFoundError:
org/apache/commons/compress/archivers/zip/ZipFile
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:298)
at org.apache.poi.ooxml.util.PackageHelper.open(PackageHelper.java:37)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:307)

The way my software attempts to embed the POI libraries is:

1. Download the distribution and unzip it,
2. Put every .jar in the lib/ directory in the classpath,
3. Put every .jar in the ooxml-lib directory in the classpath,
4. Put every .jar in the top-level directory in the classpath.

I then updated to 3.17 and this worked fine. So the breaking change
(for my code) is between 3.17 and 4.0.0.

Am I doing this right? I haven't yet started searching through the JAR
files for this class and its dependencies. I do notice that the 3.17
distribution seems to contain quite different JAR files than the 4.0.0
distribution (which contains JAXB, Java Activation Framework and so
forth), so I am guessing there was some rearchitecting of dependencies
and either there's something missing or I have to reorganize my code
loading strategy above.

Any ideas?

- David P. Caldwell
http://www.davidpcaldwell.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Classpath issues with 4.0.0

Posted by Andreas Beeker <ki...@apache.org>.
Hi David,

this will be fixed be 4.0.1 - specifically this was fixed by #62742
(https://bz.apache.org/bugzilla/show_bug.cgi?id=62742)

Please add Commons Compress 1.18 (or higher) to your classpath.
https://search.maven.org/artifact/org.apache.commons/commons-compress/1.18/jar

> The way my software attempts to embed the POI libraries is: ...
The collection seems to be ok, but you don't need the poi-examples-4.0.0.jar and probably also not the poi-excelant-4.0.0.jar.
Have a look at http://poi.apache.org/components/index.html#components for more infos.
Have you thought about using a package manager like maven or gradle?
... I would then try to add the dependency to poi-ooxml and if it fails for your usecase another to poi-scratchpad

> so I am guessing there was some rearchitecting of dependencies
Yes, hence also the version jump from 3.x to 4.x

Andi


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org