| Summary: | NPE with byte[] and @XmlValue | ||||||
|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Blaise Doughan <blaise.doughan> | ||||
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | denise.mahar | ||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 192648 [details]
Proposed changes and test
April 6th - Checked in changed to MappingsGenerator to create the appropriate mapping (xpath '.' instead of text()) The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
When I use the following class: import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlValue; @XmlRootElement public class Foo { private byte[] bytes; @XmlValue //@XmlSchemaType(name = "hexBinary") public byte[] getBytes() { return bytes; } public void setBytes(byte[] bytes) { this.bytes = bytes; } } With the following demo code: import javax.xml.bind.JAXBContext; import javax.xml.bind.Unmarshaller; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.dom.DOMSource; import org.w3c.dom.Document; import org.w3c.dom.Element; public class Demo { public static void main(String[] args) throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document document = db.newDocument(); Element element = document.createElement("foo"); element.setTextContent("YTM0NZomIzI2OTsmIzM0NTueYQ=="); JAXBContext jc = JAXBContext.newInstance(Foo.class); Unmarshaller unmarshaller = jc.createUnmarshaller(); Foo foo = (Foo) unmarshaller.unmarshal(new DOMSource(element)); System.out.println(foo.getBytes().length); jc.createMarshaller().marshal(foo, System.out); } } I get the following Exception: Exception in thread "main" java.lang.NullPointerException at forum97.Demo.main(Demo.java:23) Meaning somehow the byte[] is not being populated.