Page 1 of 1

docx4j crashes when handling pictures

PostPosted: Sat Nov 06, 2010 10:40 am
by dcole
In my custom XML binding tool - I am getting this stack trace whenever I try to have a picture, floating text box, or anything like that in the document. Do you have any plans to address this?


For Relationship Id=rId10 Source is /word/document.xml, Target is media/image1.png, type: http://schemas.openxmlformats.org/offic ... hips/image (LoadFromZipNG.java, line 342)
05.11.2010 19:14:02 *DEBUG* LoadFromZipNG: resolved uri: word/media/image1.png (LoadFromZipNG.java, line 504)
05.11.2010 19:14:02 *INFO * ContentTypeManager: Looking at extension 'png (ContentTypeManager.java, line 250)
05.11.2010 19:14:02 *INFO * ContentTypeManager: Found content type 'image/png' for /word/media/image1.png (ContentTypeManager.java, line 254)
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlgraphics/image/loader/ImageContext
at org.docx4j.openpackaging.contenttype.ContentTypeManager.newPartForContentType(ContentTypeManager.java:337)
at org.docx4j.openpackaging.contenttype.ContentTypeManager.getPart(ContentTypeManager.java:256)
at org.docx4j.openpackaging.io.LoadFromZipNG.getRawPart(LoadFromZipNG.java:511)
at org.docx4j.openpackaging.io.LoadFromZipNG.getPart(LoadFromZipNG.java:420)
at org.docx4j.openpackaging.io.LoadFromZipNG.addPartsFromRelationships(LoadFromZipNG.java:350)
at org.docx4j.openpackaging.io.LoadFromZipNG.getPart(LoadFromZipNG.java:442)
at org.docx4j.openpackaging.io.LoadFromZipNG.addPartsFromRelationships(LoadFromZipNG.java:350)
at org.docx4j.openpackaging.io.LoadFromZipNG.process(LoadFromZipNG.java:235)
at org.docx4j.openpackaging.io.LoadFromZipNG.get(LoadFromZipNG.java:188)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:188)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:169)
at CustomXmlBinding.main(CustomXmlBinding.java:109)
Caused by: java.lang.ClassNotFoundException: org.apache.xmlgraphics.image.loader.ImageContext
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 12 more

Re: docx4j crashes when handling pictures

PostPosted: Sun Nov 07, 2010 8:18 am
by jason
To handle an image, you need:

Code: Select all
      <dependency>
         <groupId>org.apache.xmlgraphics</groupId>
         <artifactId>xmlgraphics-commons</artifactId>
         <version>1.4</version>
      </dependency>


What stack trace do you get with the text box?

Re: docx4j crashes when handling pictures

PostPosted: Tue Nov 09, 2010 2:55 am
by dcole
When I built off trunk, it already had that dependency in there. I think the stack trace was for the "floating" aspect of the picture and floating text box. In other words, they werent bound to a line, I had them just floating on the document.

Re: docx4j crashes when handling pictures

PostPosted: Tue Nov 09, 2010 3:16 am
by dcole
Heres the stack trace for the floating text box

javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.internal.SAXException2: unable to marshal type "org.docx4j.wml.Pict" as an element because it is missing an @XmlRootElement annotation]
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:317)
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:243)
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:110)
at org.docx4j.XmlUtils.marshaltoW3CDomDocument(XmlUtils.java:513)
at org.docx4j.XmlUtils.marshaltoW3CDomDocument(XmlUtils.java:495)
at org.docx4j.openpackaging.parts.CustomXmlDataStoragePart.applyBindings(CustomXmlDataStoragePart.java:938)
at CustomXmlBinding.main(CustomXmlBinding.java:134)

Re: docx4j crashes when handling pictures

PostPosted: Tue Nov 09, 2010 10:18 pm
by jason

Re: docx4j crashes when handling pictures

PostPosted: Wed Nov 10, 2010 8:01 am
by dcole
Still got the same stack trace on the floating text box. A regular image works now fine, it seems

javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.internal.SAXException2: unable to marshal type "org.docx4j.wml.Pict" as an element because it is missing an @XmlRootElement annotation]
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:317)
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:243)
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:110)
at org.docx4j.XmlUtils.marshaltoW3CDomDocument(XmlUtils.java:513)
at org.docx4j.XmlUtils.marshaltoW3CDomDocument(XmlUtils.java:495)
at org.docx4j.openpackaging.parts.CustomXmlDataStoragePart.applyBindings(CustomXmlDataStoragePart.java:938)
at CustomXmlBinding.main(CustomXmlBinding.java:131)
Caused by: com.sun.istack.internal.SAXException2: unable to marshal type "org.docx4j.wml.Pict" as an element because it is missing an @XmlRootElement annotation
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:236)
at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:305)
at com.sun.xml.internal.bind.v2.runtime.property.ArrayReferenceNodeProperty.serializeListBody(ArrayReferenceNodeProperty.java:103)
at com.sun.xml.internal.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:141)
at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:321)
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:581)
at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:309)
at com.sun.xml.internal.bind.v2.runtime.property.ArrayReferenceNodeProperty.serializeListBody(ArrayReferenceNodeProperty.java:103)
at com.sun.xml.internal.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:141)
at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:321)
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:581)
at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:309)
at com.sun.xml.internal.bind.v2.runtime.property.ArrayReferenceNodeProperty.serializeListBody(ArrayReferenceNodeProperty.java:103)
at com.sun.xml.internal.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:141)
at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:321)
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:687)
at com.sun.xml.internal.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:141)
at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:321)
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:581)
at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:309)
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:482)
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:314)
... 6 more
Exception in thread "main" org.docx4j.openpackaging.exceptions.Docx4JException: Problems applying bindings
at org.docx4j.openpackaging.parts.CustomXmlDataStoragePart.applyBindings(CustomXmlDataStoragePart.java:955)
at CustomXmlBinding.main(CustomXmlBinding.java:131)
Caused by: org.docx4j.openpackaging.exceptions.Docx4JException: Null DOM Doc
at org.docx4j.XmlUtils.transform(XmlUtils.java:659)
at org.docx4j.openpackaging.parts.CustomXmlDataStoragePart.applyBindings(CustomXmlDataStoragePart.java:949)
... 1 more
Caused by: java.lang.Throwable
at org.docx4j.XmlUtils.transform(XmlUtils.java:658)
... 2 more

I fixed it by adding the annotation on the element noted in the stack trace - worked. I didnt try to add anything to your repository though (not sure I even have access)