Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 367803

Summary: @XmlValue and @XmlJoinNode conflict
Product: z_Archived Reporter: Jorge Arrieta <re.gmule+ebz>
Component: EclipselinkAssignee: Matt MacIvor <matt.macivor>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: matt.macivor
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
proposed fix and test case (trunk) none

Description Jorge Arrieta CLA 2012-01-03 17:41:52 EST
When trying to create a JAXB Context which contains the classes below:

public class VOEntryType { 
    @XmlJoinNode(referencedXmlPath = "@id_option", xmlPath = "@id")
    public Option key; 

    @XmlValue
    public Integer value;
}

and 

public class Option {
	@XmlKey
	@XmlAttribute
	@XmlJavaTypeAdapter(IntegerToStringAdapter.class)
	private int id_option;
        ...

I get the following exception:

Exception [EclipseLink-50010] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.JAXBException
Exception Description: The property or field key must be an attribute because another field or property is annotated with XmlValue.
at org.eclipse.persistence.exceptions.JAXBException.propertyOrFieldShouldBeAnAttribute(JAXBException.java:233)


Now, trying adding an attribute, like this (which, doesn't look right):

   @XmlAttribute
   @XmlJoinNode(referencedXmlPath = "@id_option", xmlPath = "@id")
    public Option key; 

Results in:

java.lang.NullPointerException at org.eclipse.persistence.jaxb.compiler.SchemaGenerator.buildSchemaComponentsForXPath(SchemaGenerator.java:1018)
Comment 1 Jorge Arrieta CLA 2012-01-03 17:56:53 EST
forgot to mention that I'm using a package level @XmlAccessorType(XmlAccessType.FIELD) annotation, haven't really checked if this is at all relevant
Comment 2 Matt MacIvor CLA 2012-01-06 13:23:54 EST
Created attachment 209142 [details]
proposed fix and test case (trunk)
Comment 3 Matt MacIvor CLA 2012-01-25 09:31:44 EST
Attached patch has been checked in to Trunk and 2.3.3.
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:04:18 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink