Community
Participate
Working Groups
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)
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