问题
docx4j (which I host) is typically used with the Sun/Oracle JAXB implementation; the classes of interest below were generated using XJC.
I thought I'd try EclipseLink MOXy, to see how it went.
On context init, I get the following error:
ERROR org.docx4j.jaxb.Context .<clinit> line 107 - Cannot initialize context
javax.xml.bind.JAXBException:
Descriptor Exceptions:
---------------------------------------------------------
Exception [EclipseLink-110] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Descriptor is missing for class [org.docx4j.vml.spreadsheetDrawing.STCF].
Mapping: org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping[moveWithCellsOrSizeWithCellsOrAnchor]
Descriptor: XMLDescriptor(org.docx4j.vml.spreadsheetDrawing.CTClientData --> [DatabaseTable(ns15:ClientData)])
Exception [EclipseLink-110] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Descriptor is missing for class [org.docx4j.bibliography.STSourceType].
Mapping: org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping[abbreviatedCaseNumberOrAlbumTitleOrAuthor]
Descriptor: XMLDescriptor(org.docx4j.bibliography.CTSourceType --> [])
Runtime Exceptions:
---------------------------------------------------------
- with linked exception:
[Exception [EclipseLink-0] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions:
---------------------------------------------------------
Exception [EclipseLink-110] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Descriptor is missing for class [org.docx4j.vml.spreadsheetDrawing.STCF].
Mapping: org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping[moveWithCellsOrSizeWithCellsOrAnchor]
Descriptor: XMLDescriptor(org.docx4j.vml.spreadsheetDrawing.CTClientData --> [DatabaseTable(ns15:ClientData)])
Exception [EclipseLink-110] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Descriptor is missing for class [org.docx4j.bibliography.STSourceType].
Mapping: org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping[abbreviatedCaseNumberOrAlbumTitleOrAuthor]
Descriptor: XMLDescriptor(org.docx4j.bibliography.CTSourceType --> [])
Runtime Exceptions:
---------------------------------------------------------
]
at org.eclipse.persistence.jaxb.JAXBContext$ContextPathInput.createContextState(JAXBContext.java:698)
at org.eclipse.persistence.jaxb.JAXBContext$ContextPathInput.createContextState(JAXBContext.java:658)
at org.eclipse.persistence.jaxb.JAXBContext.<init>(JAXBContext.java:143)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:110)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
at javax.xml.bind.ContextFinder.find(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at org.docx4j.jaxb.Context.<clinit>(Context.java:79)
at org.docx4j.samples.OpenMainDocumentAndTraverse.<clinit>(OpenMainDocumentAndTraverse.java:52)
Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions:
---------------------------------------------------------
Exception [EclipseLink-110] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Descriptor is missing for class [org.docx4j.vml.spreadsheetDrawing.STCF].
Mapping: org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping[moveWithCellsOrSizeWithCellsOrAnchor]
Descriptor: XMLDescriptor(org.docx4j.vml.spreadsheetDrawing.CTClientData --> [DatabaseTable(ns15:ClientData)])
Exception [EclipseLink-110] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Descriptor is missing for class [org.docx4j.bibliography.STSourceType].
Mapping: org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping[abbreviatedCaseNumberOrAlbumTitleOrAuthor]
Descriptor: XMLDescriptor(org.docx4j.bibliography.CTSourceType --> [])
Runtime Exceptions:
---------------------------------------------------------
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:535)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:476)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:435)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:676)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:634)
at org.eclipse.persistence.oxm.XMLContext$XMLContextState.<init>(XMLContext.java:830)
at org.eclipse.persistence.oxm.XMLContext$XMLContextState.<init>(XMLContext.java:770)
at org.eclipse.persistence.oxm.XMLContext.<init>(XMLContext.java:177)
at org.eclipse.persistence.jaxb.JAXBContext$ContextPathInput.createContextState(JAXBContext.java:726)
at org.eclipse.persistence.jaxb.JAXBContext$ContextPathInput.createContextState(JAXBContext.java:696)
... 13 more
The first pair of referenced classes, we have an enum STCF and CTClientData
The second pair of referenced classes, we have another enum STSourceType and CTSourceType
How might I workaround this problem?
回答1:
Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group.
I have been able to recreate the issue you are seeing. The issue you are seeing is due to the following bug:
- http://bugs.eclipse.org/380122
UPDATE
This issue has now been fixed in the EclipseLink 2.3.3 and 2.4.0 streams. You can download a nightly build that contains the fix from the following location:
- http://www.eclipse.org/eclipselink/downloads/nightly.php
来源:https://stackoverflow.com/questions/10680021/moxy-xmlcompositecollectionmapping-descriptor-is-missing