Some background:
I have a project which reads docx files, makes changes to the doc (changes/adds text, images, etc), then writes the changes out to a new docx file.
I've been using docx4j 2.5.0 for a little over a year now, it's been working great, very impressed with how well this library works and how easy it is to use.
Moving forward -- I need to start to support Word 2010 content, in particular mc:AlternateContent. I think using the mc:Fallback content is sufficient, which I see was added into 2.7.1. So far, so good.
So now I'm trying to migrate from 2.5.0 to 2.7.1.
A couple questions:
1) for 2.5.0, I had to have parent-pointer-plugin in my classpath .. I don't see that as part of the required libraries of docx4j anymore -- can I rip that out?
2) I did rip it out, and I'm not getting any ClassNotFoundExceptions (yet). However -- when I read a docx in, I'm getting the following exception.
I've got the docx content saved into a database in its original zipped format, so to read it, I use this:
Using java Syntax Highlighting
LoadFromZipNG loader = new LoadFromZipNG();
return (WordprocessingMLPackage)loader.get(new ByteArrayInputStream(docx));
return (WordprocessingMLPackage)loader.get(new ByteArrayInputStream(docx));
Parsed in 0.013 seconds, using GeSHi 1.0.8.4
When I call loader.get(), I'm getting the following ClassCastException in the log. However, that exception isn't being thrown, nor is any exception being thrown -- it's just being logged and I'm getting a WordprocessingMLPackage returned. So -- I'm not sure if this exception is a problem or not. I'm having a subsequent problem, but I'm not sure if it's related to this, or a problem with my code. I'll attach the full log of the docx load in case it's of any use.
- Code: Select all
java.lang.ClassCastException: org.docx4j.wml.PPr cannot be cast to javax.xml.bind.JAXBElement
at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$IntercepterLoader.intercept(ElementBeanInfoImpl.java:199)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.endElement(UnmarshallingContext.java:437)
at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.endElement(InterningXmlVisitor.java:41)
at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.endElement(SAXConnector.java:109)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:235)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:261)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:230)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:261)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:230)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:261)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:230)
at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:107)
at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:90)
at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:83)
at com.sun.xml.bind.v2.runtime.BinderImpl.associativeUnmarshal(BinderImpl.java:140)
at com.sun.xml.bind.v2.runtime.BinderImpl.unmarshal(BinderImpl.java:111)
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)
Thanks for any advice!