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

Bug 360013

Summary: Support for @XmlType and @XmlRootElement on enums
Product: z_Archived Reporter: Paul Fullbright <paul.fullbright>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: blaise.doughan, martin.grebac, matt.macivor
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Proposed Fix and Test none

Description Paul Fullbright CLA 2011-10-05 12:48:23 EDT
(found in head code)

For the following example:

@XmlType
@XmlRootElement(name="FOO")
public enum FooEnum {
	
	@XmlEnumValue("true")
	TRUE("TRUE!!!");
	
	private final String value;
	
	private FooEnum(String value) {
		this.value = value;
	}
}


creating and marshalling a single FooEnum.TRUE should create a document of the form:

<FOO>true</FOO>


The RI does support this.

Note also that the oxm.xsd does not allow for the configuration of either xml-type or xml-root-element on an xml-enum.
Comment 1 Paul Fullbright CLA 2011-10-05 12:50:19 EDT
I should note that the exception logged by moxy in this case is:


javax.xml.bind.MarshalException
 - with linked exception:
[Exception [EclipseLink-25003] (Eclipse Persistence Services - @VERSION@.@QUALIFIER@): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: An error occurred marshalling the object
Internal Exception: Exception [EclipseLink-25007] (Eclipse Persistence Services - @VERSION@.@QUALIFIER@): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: A descriptor for class testenum.FooEnum was not found in the project.  For JAXB, if the JAXBContext was bootstrapped using TypeMappingInfo[] you must call a marshal method that accepts TypeMappingInfo as an input parameter.]
...

This implies that @XmlType is being ignored as well, I think.
Comment 2 Matt MacIvor CLA 2012-03-22 14:26:09 EDT
Created attachment 213074 [details]
Proposed Fix and Test
Comment 3 Matt MacIvor CLA 2012-03-22 16:41:40 EDT
Attached patch checked in to SVN in 2.3 and 2.4 streams
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:27:10 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink