poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Burch <apa...@gagravarr.org>
Subject Re: Application fails with Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/xwpf/usermodel/XWPFDocument
Date Sun, 11 Feb 2018 11:17:11 GMT
On Sat, 10 Feb 2018, Marco Lechner - FOSSGIS e.V. wrote:
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/poi/xwpf/usermodel/XWPFDocument
>     at de.bfs.dokpool.faq.importer.FaqImporter.main(FaqImporter.java:23)
> Caused by: java.lang.ClassNotFoundException:
> org.apache.poi.xwpf.usermodel.XWPFDocument
>
> The as far as I know relevant dependency packages seem to be included in
> the jar-file. Tried with unzip -l:
>
> $ unzip -l target/dokpool-faq-importer.jar
> Archive:  target/dokpool-faq-importer.jar
>   Length      Date    Time    Name
> ---------  ---------- -----   ----
*snip*
>    190432  2018-02-09 22:18   lib/gson-2.2.4.jar
>    751238  2018-02-09 22:18   lib/commons-collections4-4.1.jar
>     26514  2018-02-09 22:18   lib/stax-api-1.0.1.jar
>   1433719  2018-02-09 22:18   lib/poi-ooxml-3.16.jar

Generally classloaders will only load classes from within a jar, not 
jars-within-jars.

If you want to only have a single jar with everything in, you'll either 
need to switch to a more "war-like" classloader to have jars within your 
jar loaded, or use something like shading/shadowing when you build the jar 
to have the classes of the dependencies in-lined within your jar

Nick

Mime
View raw message