Community
Participate
Working Groups
The JAXB standard way to marshal a byte[] to a hexBinary representation is to use javax.xml.bind.annotation.adapters.HexBinaryAdapter as a Java type adapter. In annotations this looks like: @XmlRootElement public class Customer { @XmlElement @XmlSchemaType(name="hexBinary") @XmlJavaTypeAdapter(HexBinaryAdapter.class) public byte[] hexBytes; @XmlElement public byte[] base64Bytes; } This works fine in EclipseLink, but using the equivalent OXM does not: ... <java-type name="CustomerB"> <xml-root-element name="customer"/> <java-attributes> <xml-element java-attribute="picture" xml-inline-binary-data="true"> <xml-schema-type name="hexBinary"/> <xml-java-type-adapter value="javax.xml.bind.annotation.adapters.HexBinaryAdapter"/> </xml-element> <xml-element java-attribute="resume"/> </java-attributes> </java-type> ... When marshalled, the <hexBinary> element contains empty string. This seems to stem from the fact that we go through a different code path if our adapter is not an instance of org.eclipse.persistence.oxm.mappings.converters.XMLConverter.
Created attachment 185333 [details] Test Case demonstrating bug
Created attachment 185706 [details] Proposed fix
Created attachment 185707 [details] Supporting tests
Reviewed by: matt.macivor@oracle.com Tests: all unit tests pass as expected; jaxb/externalizedmetadata/xmladapter/XmlAdapterTestCases; jaxb/xmladapter/hexbinary/XmlAdapterHexBinaryTestCases Revision: 8744
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink