Page 1 of 1

thrown exceptions in docx4j 8.3.1

PostPosted: Wed Jul 14, 2021 5:51 pm
by 12AM
regarding an old post about VariablePrepare
a new error have been thrown
org.docx4j.openpackaging.exceptions.Docx4JException: Problem saving part /_rels/.rels

another exception happen when I try to use jaxb
java.lang.ClassNotFoundException: org.docx4j.jaxb.ri.NamespacePrefixMapper

I have looked through docx4j-core and docx4j-jaxb-interanl, jaxb-internal has simmilar path org.docx4j.jaxb.suninternal.NamespacePrefixMapper
same for docx4j-core org.docx4j.jaxb.generic.NamespacePrefixMapper

hopefully it will be of some help. thank you.

Re: thrown exceptions in docx4j 8.3.1

PostPosted: Wed Jul 14, 2021 6:45 pm
by jason
You need one and only one of:

docx4j-JAXB-Internal (available for docx4j 8.x only and Oracle Java 8),
| docx4j-JAXB-MOXy (for docx4j 8 or 11),
| docx4j-JAXB-ReferenceImpl (for docx4j 8 or 11),

If you have this, please post your classpath, stack trace and steps to reproduce error.

Re: thrown exceptions in docx4j 8.3.1

PostPosted: Wed Jul 14, 2021 8:12 pm
by 12AM
org.docx4j.openpackaging.exceptions.Docx4JException: Problem saving part /_rels/.rels

java.lang.RuntimeException: javax.xml.bind.JAXBException: JAXB: Can't instantiate JAXB Reference Implementation
- with linked exception: [java.lang.ClassNotFoundException: org.docx4j.jaxb.ri.NamespacePrefixMapper]


both exceptions are thrown when using VariablePrepare and VariableReplace
I am using a maven project and using dependencies, my current classpath has ECLIPSE_HOME and M2_REPO

Re: thrown exceptions in docx4j 8.3.1

PostPosted: Wed Jul 14, 2021 8:22 pm
by 12AM
after looking at your reply I have noticed that in order to use JAXB-internal I must use docx4j 8.1.x while I am currently using 8.3.1.
by changing to the JAXB-MOXy dependency it worked. this information wasn't provided in the version release post. Hopefully you will add it.

thank you for your great help!

Re: thrown exceptions in docx4j 8.3.1

PostPosted: Fri Jul 16, 2021 11:00 am
by jason
Sorry, that was a typo; docx4j 8.3.1 should work fine with -JAXB-Internal, providing you are using a JDK which includes that JAXB (eg Oracle Java 8, not say Java 13).

I have now corrected the typo.