| Summary: | JAXBElement<Object> with XmlElementRef fails to unmarshal and marshals with no type attribute | ||||||
|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Matt MacIvor <matt.macivor> | ||||
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | ||||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 190193 [details]
Propsed fix
Attached patch checked in to SVN Reviewed by David McCann The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
Given a class with the following property: @XmlElementRef(name = "inObject", type = JAXBElement.class, required = false) protected JAXBElement<Object> inObject; When marshalling, the xsi:type is omitted: <ns0:echoAnyType xmlns:ns0="urn:test:types"><inObject>foo</inObject></ns0:echoAnyType> The correct document should contain an xsi:type="xsd:string" attribute on the inObject element. When unmarshalling, if the xsi:type attribute is present, and exception is thrown: org.eclipse.persistence.exceptions.DescriptorException Exception Description: Trying to set value [javax.xml.bind.JAXBElement@787c16] for instance variable [inObject] of type [javax.xml.bind.JAXBElement] in the object. The specified object is not an instance of the class or interface declaring the underlying field, or an unwrapping conversion has failed. Internal Exception: java.lang.IllegalArgumentException: Can not set javax.xml.bind.JAXBElement field fromwsdl.wsdl_hello_lit.client.EchoAnyType.inObject to java.lang.String Mapping: org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping[inObject] Descriptor: XMLDescriptor(fromwsdl.wsdl_hello_lit.client.EchoAnyType --> [DatabaseTable(ns0:echoAnyType)]) at org.eclipse.persistence.exceptions.DescriptorException.illegalArgumentWhileSet tingValueThruInstanceVariableAccessor(DescriptorException.java:700) at org.eclipse.persistence.internal.descriptors.InstanceVariableAttributeAccessor .setAttributeValueInObject(InstanceVariableAttributeAccessor.java:188) at org.eclipse.persistence.mappings.foundation.AbstractCompositeObjectMapping.set AttributeValueInObject(AbstractCompositeObjectMapping.java:187) at org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping.setAttributeVal ueInObject(XMLCompositeObjectMapping.java:763)