Reputation: 111
Good morning every body ,
I have java code that alllows me to create an excel file from xml flie.. But it can not create correctly the file, i have this exception that I do not inderstand its meaning :
Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException
at org.apache.poi.openxml4j.opc.Package.init(Package.java:145)
at org.apache.poi.openxml4j.opc.Package.<init>(Package.java:132)
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:67)
at org.apache.poi.openxml4j.opc.Package.create(Package.java:271)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.newPackage(XSSFWorkbook.java:245)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:145)
at escel1.Escel1.main(Escel1.java:104)
Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
If someone knows what that means , it will be very helpfull for me :)
Upvotes: 2
Views: 42075
Reputation: 4649
I have found the key about your problem. you shouldn't add the jar file of dom4j-1.6.1-sources.jar
but dom4j-1.x.jar
into the project library. Because the jar file's name with sources is pure java file(xx.java), that means it's not compiled at all.
then rebuild your project, it'll work fine.
Hope to help you :)
Upvotes: 11
Reputation: 48326
Apache POI have a handy page listing all the components and their dependencies, you should start by reading that!
Secondly, if you downloaded the binary zip/tarball of Apache POI, then it comes with all of the dependencies you need in the /lib/
and /ooxml-lib/
directories. Make sure you include all the dependencies required from there on your classpath! (You've missed some out, hence the error)
Upvotes: 2