Page 1 of 1

Missing Class / sfl4j

PostPosted: Thu Aug 22, 2013 9:53 am
by apderosso
I'm looking at the sample file "" using the docx4j source code on my build path. I've created a sample program that does exactly what I want. Now that I'm incorporating docx4j into my application, when I use the binaries from the site there seems to be a class missing. I'm trying to use:

import org.docx4j.Docx4J;

as demonstrated in the sample file.

I downloaded the latest nightly docx4j .jar which does contain the missing class, but now I'm getting class not found exceptions for slf4j. Am I missing something?

Re: Missing Class / sfl4j

PostPosted: Thu Aug 22, 2013 11:51 am
by jason
Hi, no, you are on the right track.

The nightly is what will eventually become 3.0, and it uses slf4j, instead of log4j.

You just need to add:


Re: Missing Class / sfl4j

PostPosted: Fri Aug 23, 2013 6:44 am
by apderosso
Thanks for the response Jason, I at least got that much working. But now I'm getting an error when I try to bind the xml and the template. I'm getting the following error:

org.docx4j.openpackaging.exceptions.Docx4JException: Problems creating a org.w3c.dom.Document for the passed input stream.
at org.docx4j.Docx4J.bind(

Here's my code so far:

wordMLPackage = Docx4J.load(file);
FileInputStream xmlStream = new FileInputStream(xml);
Docx4J.bind(wordMLPackage, xmlStream, Docx4J.FLAG_BIND_INSERT_XML);

I've attached the xml and the docx file that I'm using, is there something wrong with the xml or docx files?

Re: Missing Class / sfl4j

PostPosted: Fri Aug 23, 2013 1:42 pm
by jason
Yes, there's a problem with your XML file:

Caused by: Invalid byte 1 of 1-byte UTF-8 sequence.
at Source)
at Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at org.docx4j.Docx4J.bind(

the problem is at byte position 3331 (line 66): <perMill>�</perMill>

You can see this if you open it with SC UniPad, configured not to suppress load errors

Having fixed that, I see: "line 1:149 mismatched input '<EOF>' expecting LPAR" multiple times. I haven't seen that before, but it'd be from XPathEnhancerParser; possibly it doesn't like the full stop (period) characters in your xpaths? Output is produced, so it might not matter, but still, it would be good to understand/fix.

For what it is worth, I used Docx4J.FLAG_NONE (which you need to process repeats), and today's nightly, which contains a relevant fix: ... 130823.jar

Re: Missing Class / sfl4j

PostPosted: Sat Aug 24, 2013 3:30 am
by apderosso
Awesome, that fixed it. Thank you for your help Jason!