Page 1 of 1

Docx to Pdf Conversion- needs JAXB RI NamespacePrefixMapper?

PostPosted: Tue Aug 10, 2010 11:21 pm
by heitorflorido
Hello,
I'm using docx4j 2.5.0 to write some docx files and it's working great!
Now I want to convert these files to Pdf and I'm getting this error:
Code: Select all
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/xml/bind/marshaller/NamespacePrefixMapper
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClassCond(Unknown Source)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   at java.security.SecureClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.access$000(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at org.docx4j.XmlUtils.JAXBElementDebug(XmlUtils.java:180)
   at org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart.traverseMainDocumentRecursive(MainDocumentPart.java:530)
   at org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart.traverseMainDocumentRecursive(MainDocumentPart.java:479)
   at org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart.traverseMainDocumentRecursive(MainDocumentPart.java:450)
   at org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart.fontsInUse(MainDocumentPart.java:325)
   at org.docx4j.openpackaging.packages.WordprocessingMLPackage.setFontMapper(WordprocessingMLPackage.java:323)
   at spt.Main.main(Main.java:63)
Caused by: java.lang.ClassNotFoundException: com.sun.xml.bind.marshaller.NamespacePrefixMapper
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 19 more


I'm using Eclipse helios, JDK 1.6.0_20.

I've read on another thread that I should download a JAXB RI and put it my endorsed libs dir, but I don't know how to do it.
Anyone can help me?

Heitor

Re: Docx to Pdf Conversion

PostPosted: Wed Aug 11, 2010 1:28 am
by jason
Hi, you should only need both implementations of JAXB if you are building from source.

If you are not building from source, then this is a bug, which I just fixed. See http://dev.plutext.org/trac/docx4j/changeset/1184 (hmm, you'll need to build from source to get this, or wait for a nightly. In the meantime, you can use the endorsed dir mechanism: in Eclipse, its Run > Run Configurations, then add the VM argument -Djava.endorsed.dirs=etc).

If you are building from source, then you need both JAXB implementations. You need both, so that com/sun/xml/bind/marshaller/NamespacePrefixMapper is found at build time. Your RI does not need to be in an endorsed dir for this to be the case I don't think - it just needs to be on your class path. And the Maven POM should take care of this if you use m2eclipse.

Re: Docx to Pdf Conversion- needs JAXB RI NamespacePrefixMapper?

PostPosted: Thu Aug 12, 2010 10:38 pm
by heitorflorido
While I'm waiting for a nightly build, which folder should I my -Djava.endorsed.dirs should point to?
The JAXB RI jar should be there too?

Thanks

Heitor Florido

Re: Docx to Pdf Conversion- needs JAXB RI NamespacePrefixMapper?

PostPosted: Sat Aug 14, 2010 5:56 pm
by jason
Point -Djava.endorsed.dirs to wherever you put the JAXB RI.

Anyway, you can now try http://dev.plutext.org/docx4j/docx4j-ni ... 100814.jar

Re: Docx to Pdf Conversion- needs JAXB RI NamespacePrefixMapper?

PostPosted: Mon Aug 16, 2010 11:48 pm
by heitorflorido
jason, now the PDF conversion is working. Thanks man.

However, I have some questions about the output file. I'm going to open another thead for this.

Should I edit this post title and add [SOLVED] to it?

Thanks again