Page 1 of 1

IllegalAnnotationsException on loading docx file

PostPosted: Tue Apr 05, 2011 2:21 am
by kohus
Hi!

On executing the following code

try {
File f = new File(filename);
wordMLPackage = WordprocessingMLPackage.load(f);
} catch (Docx4JException e1) {
throw new GeneratorException("Wrong document",e1);
}
I got an exception. I have no idea why it happens, could you please help?

com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 3 counts of IllegalAnnotationExceptions
@XmlAttribute/@XmlValue need to reference a Java type that maps to text in XML.
this problem is related to the following location:
at protected javax.xml.datatype.XMLGregorianCalendar org.docx4j.wml.CTTrackChange.date
at org.docx4j.wml.CTTrackChange
at org.docx4j.wml.CTRPrChange
at protected org.docx4j.wml.CTRPrChange org.docx4j.wml.RPr.rPrChange
at org.docx4j.wml.RPr
at protected org.docx4j.wml.RPr org.docx4j.wml.R.rPr
at org.docx4j.wml.R
at protected java.util.List org.docx4j.wml.RunDel.customXmlOrSmartTagOrSdt
at org.docx4j.wml.RunDel
at protected java.util.List org.docx4j.wml.RunIns.customXmlOrSmartTagOrSdt
at org.docx4j.wml.RunIns
at protected java.util.List org.docx4j.wml.Comments$Comment.egBlockLevelElts
at org.docx4j.wml.Comments$Comment
at protected java.util.List org.docx4j.wml.Comments.comment
at org.docx4j.wml.Comments
at public org.docx4j.wml.Comments org.docx4j.wml.ObjectFactory.createComments()
at org.docx4j.wml.ObjectFactory
@XmlAttribute/@XmlValue need to reference a Java type that maps to text in XML.
this problem is related to the following location:
at protected javax.xml.datatype.XMLGregorianCalendar org.docx4j.wml.CTSdtDate.fullDate
at org.docx4j.wml.CTSdtDate
at public org.docx4j.wml.CTSdtDate org.docx4j.wml.ObjectFactory.createCTSdtDate()
at org.docx4j.wml.ObjectFactory
@XmlAttribute/@XmlValue need to reference a Java type that maps to text in XML.
this problem is related to the following location:
at protected javax.xml.datatype.XMLGregorianCalendar org.docx4j.wml.CTMoveBookmark.date
at org.docx4j.wml.CTMoveBookmark
at public org.docx4j.wml.CTMoveBookmark org.docx4j.wml.ObjectFactory.createCTMoveBookmark()
at org.docx4j.wml.ObjectFactory

at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:436)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:277)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1100)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:143)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:110)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:191)
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:128)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:290)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)
at org.docx4j.jaxb.Context.<clinit>(Context.java:74)
at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:619)
at org.docx4j.openpackaging.io.LoadFromZipNG.process(LoadFromZipNG.java:200)
at org.docx4j.openpackaging.io.LoadFromZipNG.get(LoadFromZipNG.java:189)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:188)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:169)

Re: IllegalAnnotationsException on loading docx file

PostPosted: Tue Apr 05, 2011 9:31 am
by jason
Which version of JAXB are you using? If you are not using a JAXB reference implementation, what version of Java?

Try using a recent JAXB 2.1.x eg JAXB 2.1.13 (the reference implementation of 2010 05 11).

If you are using Java 6, you'll need to use the endorsed dir mechanism.