ClassNotFoundException: org.docx4j.openpackaging.exceptions.Docx4JException
So let's go again. My head is banging on my computer for about a few hours, I can't figure out what to do. On my local PC, I am running Java code from Intellij Idea . It works. Now I need to create a file jar
so that he can use it on some remote server. I added all the libraries, banks that my program needs in the project settings (added libraries in the "Artifacts" section). But it doesn't work on the remote server. What my program imports:
import org.docx4j.dml.CTBlip;
import org.docx4j.jaxb.XPathBinderAssociationIsPartialException;
import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.docx4j.openpackaging.parts.PartName;
import org.docx4j.openpackaging.parts.relationships.RelationshipsPart;
import org.docx4j.relationships.Relationship;
import javax.xml.bind.JAXBException;
import java.io.File;
import java.util.List;
Mistake:
Exception in thread "main" java.lang.NoClassDefFoundError: org/docx4j/openpackaging/exceptions/Docx4JException
Caused by: java.lang.ClassNotFoundException: org.docx4j.openpackaging.exceptions.Docx4JException
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: Main. Program will exit.
Is this the problem of creating a bank? Did I miss something?
source to share
I faced a similar issue where the original docx4j jars were not loaded by the classloader.
I've tried these:
- docx4j-3.1.0.jar
- docx4j-3.2.1.jar
For some reason Midnight Commander was unable to open them (by pressing enter) on the first try and reported "Inconsistent extfs archive". The problem was solved by recreational recreation
# run in a directory containing just single original docx4j jar file
unzip docx4j-3.2.1.jar
rm -r docx4j-3.2.1.jar
jar cf docx4j-3.2.1.jar *
Now the new jar opens in MC without any problems (at least in my case) and its classes are loaded and java.lang.NoClassDefFoundError
not thrown away anymore.
UPDATE
JIC, I just checked which JDK the box I was using belongs to.
This is OpenJDK 64-bit 1.7.0_79, Linux Mint 17.
source to share