Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 361689 - NPE thrown when @XmlValue mapping attempts to write xsi:type
Summary: NPE thrown when @XmlValue mapping attempts to write xsi:type
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL: http://stackoverflow.com/questions/78...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-21 12:43 EDT by Blaise Doughan CLA
Modified: 2022-06-09 10:26 EDT (History)
0 users

See Also:


Attachments
MOXy - Test Cases (4.85 KB, patch)
2012-03-15 16:00 EDT, Blaise Doughan CLA
no flags Details | Diff
Core - Fix (1.18 KB, patch)
2012-03-15 16:01 EDT, Blaise Doughan CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Blaise Doughan CLA 2011-10-21 12:43:00 EDT
If you attempt to marshal an object like the following a NPE will be thrown when an xsi:type attribute needs to be written for the @XmlValue property.

import javax.xml.bind.annotation.*;

@XmlAccessorType(XmlAccessType.FIELD)
public class Field {
    @XmlAttribute
    private String name;

    @XmlValue
    Object value;

}

Exception

Exception in thread "main" javax.xml.bind.MarshalException
 - with linked exception:
[Exception [EclipseLink-25003] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: An error occurred marshalling the object
Internal Exception: java.lang.NullPointerException]
	at org.eclipse.persistence.jaxb.JAXBMarshaller.marshal(JAXBMarshaller.java:314)
	at forum7851506.Demo.main(Demo.java:20)
Caused by: Exception [EclipseLink-25003] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: An error occurred marshalling the object
Internal Exception: java.lang.NullPointerException
	at org.eclipse.persistence.exceptions.XMLMarshalException.marshalException(XMLMarshalException.java:78)
	at org.eclipse.persistence.oxm.XMLMarshaller.marshal(XMLMarshaller.java:516)
	at org.eclipse.persistence.jaxb.JAXBMarshaller.marshal(JAXBMarshaller.java:312)
	... 1 more
Caused by: java.lang.NullPointerException
	at org.eclipse.persistence.oxm.record.OutputStreamRecord.outputStreamWrite(OutputStreamRecord.java:511)
	at org.eclipse.persistence.oxm.record.FormattedOutputStreamRecord.openStartElement(FormattedOutputStreamRecord.java:84)
	at org.eclipse.persistence.internal.oxm.XPathNode.startElement(XPathNode.java:330)
	at org.eclipse.persistence.internal.oxm.XMLCompositeObjectMappingNodeValue.marshalSingleValue(XMLCompositeObjectMappingNodeValue.java:185)
	at org.eclipse.persistence.internal.oxm.XMLCompositeObjectMappingNodeValue.marshal(XMLCompositeObjectMappingNodeValue.java:116)
	at org.eclipse.persistence.internal.oxm.NodeValue.marshal(NodeValue.java:104)
	at org.eclipse.persistence.internal.oxm.record.ObjectMarshalContext.marshal(ObjectMarshalContext.java:60)
	at org.eclipse.persistence.internal.oxm.XPathNode.marshal(XPathNode.java:322)
	at org.eclipse.persistence.internal.oxm.TreeObjectBuilder.buildRow(TreeObjectBuilder.java:325)
	at org.eclipse.persistence.internal.oxm.XMLCompositeObjectMappingNodeValue.marshalSingleValue(XMLCompositeObjectMappingNodeValue.java:176)
	at org.eclipse.persistence.internal.oxm.XMLCompositeObjectMappingNodeValue.marshal(XMLCompositeObjectMappingNodeValue.java:116)
	at org.eclipse.persistence.internal.oxm.NodeValue.marshal(NodeValue.java:104)
	at org.eclipse.persistence.internal.oxm.record.ObjectMarshalContext.marshal(ObjectMarshalContext.java:60)
	at org.eclipse.persistence.internal.oxm.XPathNode.marshal(XPathNode.java:322)
	at org.eclipse.persistence.internal.oxm.TreeObjectBuilder.buildRow(TreeObjectBuilder.java:325)
	at org.eclipse.persistence.oxm.XMLMarshaller.marshal(XMLMarshaller.java:932)
	at org.eclipse.persistence.oxm.XMLMarshaller.marshal(XMLMarshaller.java:486)
	... 2 more
Comment 1 Blaise Doughan CLA 2012-03-15 16:00:45 EDT
Created attachment 212752 [details]
MOXy - Test Cases
Comment 2 Blaise Doughan CLA 2012-03-15 16:01:16 EDT
Created attachment 212753 [details]
Core - Fix
Comment 3 Blaise Doughan CLA 2012-03-16 12:31:35 EDT
Fix checked into 2.3.3 at rev:  11004
Fix checked into trunk at rev:  11005

Code reviewed by:  Matt MacIvor

Fix Details:
When writing out text in XMLCompositeObjectMappingNode value treat the XPath "@text" like ".".
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:26:11 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink