4

docx4j (which I host) is typically used with the Sun/Oracle JAXB implementation; the classes of interest below were generated using XJC.

Following on from an earlier issue which the MOXy guys kindly fixed, I'm continuing to try to get it working with EclipseLink MOXy.

With a particular DOM document, I'm now getting:

[Exception [EclipseLink-25004] (Eclipse Persistence Services - 2.4.0.v20120529-r11529): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: An error occurred unmarshalling the document
Internal Exception: Exception [EclipseLink-116] (Eclipse Persistence Services - 2.4.0.v20120529-r11529): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: No conversion value provided for the value [1] in field [@ns1:val].
Mapping: org.eclipse.persistence.oxm.mappings.XMLDirectMapping[val-->@ns1:val]
Descriptor: XMLDescriptor(org.docx4j.math.CTOnOff --> [])]
    at org.eclipse.persistence.jaxb.JAXBBinder.unmarshal(JAXBBinder.java:100)
    at org.docx4j.openpackaging.parts.JaxbXmlPartXPathAware.unmarshal(JaxbXmlPartXPathAware.java:211)
    at org.docx4j.openpackaging.io.LoadFromZipNG.getRawPart(LoadFromZipNG.java:556)
    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.process(LoadFromZipNG.java:243)
    at org.docx4j.openpackaging.io.LoadFromZipNG.get(LoadFromZipNG.java:193)
    at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:301)
    at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:245)
    at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:195)
    at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:178)
    at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:172)
    at org.docx4j.samples.OpenAndSaveRoundTripTest.main(OpenAndSaveRoundTripTest.java:60)
Caused by: Exception [EclipseLink-25004] (Eclipse Persistence Services - 2.4.0.v20120529-r11529): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: An error occurred unmarshalling the document
Internal Exception: Exception [EclipseLink-116] (Eclipse Persistence Services - 2.4.0.v20120529-r11529): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: No conversion value provided for the value [1] in field [@ns1:val].
Mapping: org.eclipse.persistence.oxm.mappings.XMLDirectMapping[val-->@ns1:val]
Descriptor: XMLDescriptor(org.docx4j.math.CTOnOff --> [])
    at org.eclipse.persistence.exceptions.XMLMarshalException.unmarshalException(XMLMarshalException.java:109)
    at org.eclipse.persistence.internal.oxm.XMLCompositeObjectMappingNodeValue.startElement(XMLCompositeObjectMappingNodeValue.java:328)
    at org.eclipse.persistence.oxm.record.UnmarshalRecord.startElement(UnmarshalRecord.java:783)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:147)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.handleChildNodes(DOMReader.java:250)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:148)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.handleChildNodes(DOMReader.java:250)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:148)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.handleChildNodes(DOMReader.java:250)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:148)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.handleChildNodes(DOMReader.java:250)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:148)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.handleChildNodes(DOMReader.java:250)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:148)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.handleChildNodes(DOMReader.java:250)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:148)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.handleChildNodes(DOMReader.java:250)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:148)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.handleChildNodes(DOMReader.java:250)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:148)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.handleChildNodes(DOMReader.java:250)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:148)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.parse(DOMReader.java:89)
    at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:462)
    at org.eclipse.persistence.oxm.XMLBinder.unmarshal(XMLBinder.java:84)
    at org.eclipse.persistence.jaxb.JAXBBinder.unmarshal(JAXBBinder.java:89)
    ... 12 more
Caused by: Exception [EclipseLink-116] (Eclipse Persistence Services - 2.4.0.v20120529-r11529): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: No conversion value provided for the value [1] in field [@ns1:val].
Mapping: org.eclipse.persistence.oxm.mappings.XMLDirectMapping[val-->@ns1:val]
Descriptor: XMLDescriptor(org.docx4j.math.CTOnOff --> [])
    at org.eclipse.persistence.oxm.record.UnmarshalRecord.startElement(UnmarshalRecord.java:851)
    at org.eclipse.persistence.internal.oxm.XMLRelationshipMappingNodeValue.processChild(XMLRelationshipMappingNodeValue.java:91)
    at org.eclipse.persistence.internal.oxm.XMLCompositeObjectMappingNodeValue.startElement(XMLCompositeObjectMappingNodeValue.java:323)
    ... 36 more
Caused by: Exception [EclipseLink-116] (Eclipse Persistence Services - 2.4.0.v20120529-r11529): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: No conversion value provided for the value [1] in field [@ns1:val].
Mapping: org.eclipse.persistence.oxm.mappings.XMLDirectMapping[val-->@ns1:val]
Descriptor: XMLDescriptor(org.docx4j.math.CTOnOff --> [])
    at org.eclipse.persistence.exceptions.DescriptorException.noFieldValueConversionToAttributeValueProvided(DescriptorException.java:1052)
    at org.eclipse.persistence.mappings.converters.ObjectTypeConverter.convertDataValueToObjectValue(ObjectTypeConverter.java:140)
    at org.eclipse.persistence.oxm.mappings.XMLDirectMapping.getAttributeValue(XMLDirectMapping.java:287)
    at org.eclipse.persistence.internal.oxm.XMLDirectMappingNodeValue.attribute(XMLDirectMappingNodeValue.java:153)
    at org.eclipse.persistence.oxm.record.UnmarshalRecord.startElement(UnmarshalRecord.java:834)
    ... 38 more

That was with JAXBBinder.unmarshall. The same thing occurs if I use JAXBUnmarshaller.unmarshal:

[Exception [EclipseLink-25004] (Eclipse Persistence Services - 2.4.0.v20120529-r11529): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: An error occurred unmarshalling the document
Internal Exception: Exception [EclipseLink-116] (Eclipse Persistence Services - 2.4.0.v20120529-r11529): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: No conversion value provided for the value [1] in field [@ns1:val].
Mapping: org.eclipse.persistence.oxm.mappings.XMLDirectMapping[val-->@ns1:val]
Descriptor: XMLDescriptor(org.docx4j.math.CTOnOff --> [])]
    at org.eclipse.persistence.jaxb.JAXBUnmarshaller.handleXMLMarshalException(JAXBUnmarshaller.java:956)
    at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:210)

The XML file causing the breakage may be found at https://gist.github.com/2834081 and org.docx4j.math.CTOnOff is here.

Any suggestions?

Community
  • 1
  • 1
JasonPlutext
  • 15,352
  • 4
  • 44
  • 84

1 Answers1

5

Note: I'm the EclipseLink JAXB (MOXy) lead an a member of the JAXB (JSR-222) expert group.

The XML document being unmarshalled is actually invalid. If the value in the ns1:val attribute is changed to match the allowed enum values then everything works as expected.

XML File

Line 95 of the xml doc is this

<m:radPr>
    <m:degHide m:val="1" />

STOnOff

1 is not a valid value...should be "on" or "off"

@XmlType(name = "ST_OnOff")
@XmlEnum
public enum STOnOff {

    @XmlEnumValue("on")
    ON("on"),
    @XmlEnumValue("off")
    OFF("off");
    private final String value;

}

CTRadPr

public class CTRadPr  implements Child
{
    protected CTOnOff degHide;
    protected CTCtrlPr ctrlPr;
    ...
}

CTOnOff

@XmlType(name = "CT_OnOff")
public class CTOnOff  implements Child
{
    @XmlAttribute(namespace = "http://schemas.openxmlformats.org/officeDocument/2006/math")
    protected STOnOff val;

There is a bug in MOXy related to handling the invalid value. What MOXy should do is when it spots the invalid value it should report an error to the ValidationEventHandler. If the ValidationEventHandler handles the event then a value will not be set for the corresponding field/property. When you try this with the JAXB RI you will see that the invalid values are not populated in the object model

You can use the following bug to track our progress on this issue:


UPDATE

We have fixed bug 381217 in the EclipseLink 2.4.0 stream. You can download a nightly label from the following location:

Note: With the fix, MOXy will report a validation event for the invalid attribute value just as it would for an invalid element value. This is different) behaviour from the JAXB-RI which throws validation events for invalid elements but not invalid attributes. I believe the RI behaviour is a bug.

bdoughan
  • 147,609
  • 23
  • 300
  • 400
  • Thanks Blaise, sorry you had to discover the XML was invalid (a docx emitted by Word which doesn't comply with their standard!). I didn't think to check this before posting (as you note, the RI didn't trip up on this). – JasonPlutext Jun 06 '12 at 01:03