Page 1 of 1

ClassCastException: org.docx4j.wml.TblPr cannot be cast...

PostPosted: Thu Apr 12, 2012 6:22 am
by Nanocom
Hi,

I have a problem when I try to load a .docx file with "a lot opf stuff in it" (images in header and footer, etc).
I don't have this problem when I try with a simple document (just text).
Here is my stack trace :

Code: Select all
java.lang.ClassCastException: org.docx4j.wml.TblPr cannot be cast to javax.xml.bind.JAXBElement
   at com.sun.xml.internal.bind.v2.runtime.ElementBeanInfoImpl$IntercepterLoader.intercept(ElementBeanInfoImpl.java:230)
   at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.endElement(UnmarshallingContext.java:505)
   at com.sun.xml.internal.bind.v2.runtime.unmarshaller.InterningXmlVisitor.endElement(InterningXmlVisitor.java:66)
   at com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.endElement(SAXConnector.java:145)
   at com.sun.xml.internal.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:239)
   at com.sun.xml.internal.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:265)
   at com.sun.xml.internal.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:234)
   at com.sun.xml.internal.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:265)
   at com.sun.xml.internal.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:234)
   at com.sun.xml.internal.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:265)
   at com.sun.xml.internal.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:234)
   at com.sun.xml.internal.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:111)
   at com.sun.xml.internal.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:94)
   at com.sun.xml.internal.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:87)
   at com.sun.xml.internal.bind.v2.runtime.BinderImpl.associativeUnmarshal(BinderImpl.java:145)
   at com.sun.xml.internal.bind.v2.runtime.BinderImpl.unmarshal(BinderImpl.java:116)
   at org.docx4j.openpackaging.parts.WordprocessingML.HeaderPart.unmarshal(HeaderPart.java:197)
   at org.docx4j.openpackaging.parts.WordprocessingML.HeaderPart.unmarshal(HeaderPart.java:48)
   at org.docx4j.openpackaging.io.LoadFromZipNG.getRawPart(LoadFromZipNG.java:551)
   at org.docx4j.openpackaging.io.LoadFromZipNG.getPart(LoadFromZipNG.java:427)
   at org.docx4j.openpackaging.io.LoadFromZipNG.addPartsFromRelationships(LoadFromZipNG.java:350)
   at org.docx4j.openpackaging.io.LoadFromZipNG.getPart(LoadFromZipNG.java:449)
   at org.docx4j.openpackaging.io.LoadFromZipNG.addPartsFromRelationships(LoadFromZipNG.java:350)
   at org.docx4j.openpackaging.io.LoadFromZipNG.process(LoadFromZipNG.java:243)
   at org.docx4j.openpackaging.io.LoadFromZipNG.get(LoadFromZipNG.java:193)
   at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:225)
   at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:177)
   at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:172)

Re: ClassCastException: org.docx4j.wml.TblPr cannot be cast.

PostPosted: Thu Apr 12, 2012 8:34 am
by jason
Could you please make and post a sample docx which exhibits the problem?

It looks like what is required to reproduce is a header with a table in it.

What JRE are you using, exactly? (this will tell us which JAXB)

Re: ClassCastException: org.docx4j.wml.TblPr cannot be cast.

PostPosted: Thu Apr 12, 2012 6:57 pm
by Nanocom
Thanks for the quick reply.
My JRE : 1.6.0_24-b07
I cannot give you the docx here, but there is indeed a table in the header, and an image.
Forgot to say that it worked with the 2.7.0

Re: ClassCastException: org.docx4j.wml.TblPr cannot be cast.

PostPosted: Thu Apr 12, 2012 7:57 pm
by jason
You don't have to post your sensitive document, but you do need to make up a docx which exhibits the same symptoms if I'm to look at your problem.

I suggest you start by copying the header with the table to a new docx, check it is still problematic, and then simplify/de-sensitize it (checking that it still exhibits the problem for you). Post the result here, or email it to me.

Re: ClassCastException: org.docx4j.wml.TblPr cannot be cast.

PostPosted: Thu Apr 12, 2012 8:23 pm
by jason
It is very likely you are experiencing http://java.net/jira/browse/JAXB-874 which http://www.docx4java.org/trac/docx4j/changeset/1736 works around. Try a recent nightly build.

Re: ClassCastException: org.docx4j.wml.TblPr cannot be cast.

PostPosted: Thu Apr 12, 2012 8:38 pm
by Nanocom
So, the problem seems to be floating images : "in front of text", in headers.
I don't have this problem when I put the image in the main document (not in the header).
See the attachments.
And thank you :)

Re: ClassCastException: org.docx4j.wml.TblPr cannot be cast.

PostPosted: Thu Apr 12, 2012 8:41 pm
by Nanocom
And indeed, my problem seems related to the one you linked

Re: ClassCastException: org.docx4j.wml.TblPr cannot be cast.

PostPosted: Thu Apr 12, 2012 9:14 pm
by Nanocom
Ok, just used the latest 2.8.0 snapshot and it worked :)
Thanks.