I want to use docx4j with some programes I've written a while ago as an outputting method.
As my first try, I wanted to simply read a docx-File but the few lines:
- Code: Select all
package word;
import java.io.File;
import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
public class ReadDocX {
public static void main(String[] args) throws Docx4JException {
String inputfilepath = "bsp/test.docx";
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage
.load(new File(inputfilepath));
}
}
are causing me the following error-messages:
- Code: Select all
0 [main] INFO org.docx4j.utils.Log4jConfigurator - Since your log4j configuration (if any) was not found, docx4j has configured log4j automatically.
198 [main] INFO org.docx4j.jaxb.Context - JAXB: RI not present. Trying Java 6 implementation.
199 [main] INFO org.docx4j.jaxb.Context - JAXB: Using Java 6 implementation.
199 [main] INFO org.docx4j.jaxb.Context - loading Context jc
210 [main] ERROR org.docx4j.jaxb.Context - Cannot initialize context
java.lang.NullPointerException
at javax.xml.bind.ContextFinder.find(ContextFinder.java:270)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)
at org.docx4j.jaxb.Context.<clinit>(Context.java:76)
at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:643)
at org.docx4j.openpackaging.io.LoadFromZipNG.process(LoadFromZipNG.java:206)
at org.docx4j.openpackaging.io.LoadFromZipNG.get(LoadFromZipNG.java:193)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:198)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:170)
at word.ReadDocX.main(ReadDocX.java:13)
213 [main] ERROR org.docx4j.openpackaging.contenttype.ContentTypeManager - java.lang.NullPointerException
Exception in thread "main" org.docx4j.openpackaging.exceptions.InvalidFormatException: Bad [Content_Types].xml
at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:676)
at org.docx4j.openpackaging.io.LoadFromZipNG.process(LoadFromZipNG.java:206)
at org.docx4j.openpackaging.io.LoadFromZipNG.get(LoadFromZipNG.java:193)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:198)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:170)
at word.ReadDocX.main(ReadDocX.java:13)
Caused by: java.lang.NullPointerException
at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:643)
... 5 more
I'm using:
Eclipse - version: 3.5.2
Java - version "1.6.0_26" (x86)
Win7 Professional x64
As u can see on the linked image, I've put the docx4j-jar's into a "UserLibrary" and linked it with my project.
Am I missing some important steps for using docx4j? I couldn't find some instructions for proper using in eclipse on the documentation.
And please don't tease me if the solution is just too easy.. ^^
Looking forward for any helpful answer
Dennis