Page 1 of 1

Cause of javax.xml.bind.JAXBException: "org.docx4j.wmll"...

PostPosted: Sat Jun 20, 2009 4:14 am
by Leigh
Hi,

Let me say in advance I know my question is vague. I am mainly looking for hints or a push in the right direction.

I am trying to troubleshoot a problem with integrating the docx4j jar into an external web application. The application runs on java 1.6, and uses several (older) versions of some of docx4j dependency jars (jaxb, iText, xalan, etcetera). The docx4j jar works fine from Eclipse. So the problem is definitely the web application environment.

So with that in mind, can anyone explain and/or suggest possible causes of the exception below? As I am not very familiar with jaxb, any thoughts would be greatly appreciated.

-Leigh

Code: Select all
javax.xml.bind.JAXBException: "org.docx4j.wml" doesnt contain ObjectFactory.class or jaxb.index
   at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:147)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:133)
   at javax.xml.bind.ContextFinder.find(ContextFinder.java:299)
   at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
   at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)
   at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:244)
   at org.docx4j.jaxb.Context.<clinit>(Context.java:39)
   at org.docx4j.openpackaging.parts.JaxbXmlPart.<init>(JaxbXmlPart.java:71)
   at org.docx4j.openpackaging.parts.relationships.RelationshipsPart.<init>(RelationshipsPart.java:160)
   at org.docx4j.openpackaging.io.LoadFromZipNG.getRelationshipsPartFromZip(LoadFromZipNG.java:265)
   at org.docx4j.openpackaging.io.LoadFromZipNG.process(LoadFromZipNG.java:215)
   at org.docx4j.openpackaging.io.LoadFromZipNG.get(LoadFromZipNG.java:180)
   at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:163)

Re: Cause of javax.xml.bind.JAXBException: "org.docx4j.wmll"...

PostPosted: Sat Jun 20, 2009 6:09 am
by jason
Hi Leigh

I haven't seen that before.

The wml class definitely contains an ObjectFactory, so it could well be the older version of JAXB getting confused.

what version of JAXB is in the webapp (or is it using the JAXB in the JRE)? What webapp container is it (ie Tomcat, or something else)? Can you put JAXB in your JRE (or container's) endorsed dir?

cheers

Jason

Re: Cause of javax.xml.bind.JAXBException: "org.docx4j.wmll"...

PostPosted: Mon Jun 22, 2009 5:31 am
by Leigh
Hi Jason,

Thanks for the response. I will have to get back to this one later in the week. I think it may be a combination of things. So I want to get my test results straight first, before sending anyone off on a wild goose chase.

-Leigh

Re: Cause of javax.xml.bind.JAXBException: "org.docx4j.wmll"...

PostPosted: Fri Jul 10, 2009 5:29 am
by Leigh
Hi Jason,


I am just getting back to this one. I re-ran all of my tests and eventually figured out it was a combination of things:

Environment: JRUN/jre 1.6
Jars: There is also an older version of jaxb (1.0.5?) and several other jars (iText, etcetera) in the classpath.

As a lot of existing functionality depends on the older jars, I wanted to make as few changes as possible (including the endorsed dirs). So one of my tests used an external classloader, in an attempt to avoid version issues. But I suspect the combination of all of these things was too much. Too bad. It would have been a very clean option ;) But I think the classloader sorcery along with the two versions of jaxb was just one straw too many ..

Anyway, that is the background behind the error above. I eventually got things working by changing the code to use the internal javax.xml.internal.bind.* classes, where indicated, and placing all of the jars in the classpath ;) Phew!

Cheers,
Leigh

Re: Cause of javax.xml.bind.JAXBException: "org.docx4j.wmll"...

PostPosted: Fri Jul 10, 2009 8:58 am
by jason
Hi Leigh

I'm glad you were able to get things working :-)

Leigh wrote:Jars: There is also an older version of jaxb (1.0.5?) and several other jars (iText, etcetera) in the classpath.


I was doing some work the other day on the Java Web Start jnlp for docx4all, and I noticed that MANIFEST.MF in JAXB RI 2.1.7 contains a class-path entry for jaxb1-impl.jar (Java Web Start tries to load jars so listed). It seemed odd to me that the 2.1.7 implementation would reference the 1.x impl. Is it possible that this is how the older version got onto your path?

cheers

Jason

Re: Cause of javax.xml.bind.JAXBException: "org.docx4j.wmll"...

PostPosted: Fri Jul 10, 2009 9:23 pm
by Leigh
Jason,

Yes, so am I! ;-)

It seemed odd to me that the 2.1.7 implementation would reference the 1.x impl. Is it possible that this is how the older version got onto your path?


Yes, I had a similar thought when I discovered the two versions (jaxb 2 from jre + jaxb 1.05). But thought maybe it was specific to my custom environment. However, you might be on to something. If I am interpreting this FAQ correctly, the 1.x impl seems to be used for backward compatibility, which would explain it all.

Q. Can I run my existing JAXB 1.0.x applications on the JAXB 2.0 runtime?
A. Yes. You just need to make sure that you deploy the jaxb1-impl.jar with your application.
https://jaxb.dev.java.net/faq/index.html


Cheers,
Leigh