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

Bug 355393

Summary: convertToXML throwing SAXException2 for missing @XmlRootElement annotation
Product: z_Archived Reporter: Kathy Carroll <carrollk>
Component: EDTAssignee: Project Inbox <edt.compiler-inbox>
Status: CLOSED FIXED QA Contact:
Severity: blocker    
Priority: P3 CC: jqian, jvincens, pharmon, tww
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Kathy Carroll CLA 2011-08-22 10:16:15 EDT
My code looks right to me but doesn't run as desired.

program driver type BasicProgram {}
	function main()		
		stdOutLog myLog;
		stdOutLog.msg = "Something here";
		xml2 String = XMLLib.convertToXML(stdOutLog, false);
		syslib.writestdout(xml2);
	end
end

record myLog {@XMLRootElement {}}
	msg string;
end

When execute program I get: 

javax.xml.bind.MarshalException
 - with linked exception:
[com.sun.istack.internal.SAXException2: unable to marshal type "stuffpkg.myLog" as an element because it is missing an @XmlRootElement annotation]
egl.lang.AnyException javax.xml.bind.MarshalException
 - with linked exception:
[com.sun.istack.internal.SAXException2: unable to marshal type "stuffpkg.myLog" as an element because it is missing an @XmlRootElement annotation]
Caused by: javax.xml.bind.MarshalException
 - with linked exception:
[com.sun.istack.internal.SAXException2: unable to marshal type "stuffpkg.myLog" as an element because it is missing an @XmlRootElement annotation]
	at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(Unknown Source)
	at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(Unknown Source)
	at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(Unknown Source)
	at eglx.xml.XmlLib.convertToXML(XmlLib.java:47)
	at stuffpkg.driver.main(driver.java:33)
	at org.eclipse.edt.javart.resources.ProgramBase._start(ProgramBase.java:81)
	at org.eclipse.edt.javart.resources.RunUnitBase.start(RunUnitBase.java:282)
	at stuffpkg.driver.main(driver.java:20)
Caused by: com.sun.istack.internal.SAXException2: unable to marshal type "stuffpkg.myLog" as an element because it is missing an @XmlRootElement annotation
	at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.reportError(Unknown Source)
	at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(Unknown Source)
	at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(Unknown Source)
	... 8 more
Comment 1 Joseph Vincens CLA 2011-08-22 11:05:28 EDT
In the generator there is a template defined for the part eglx.xml.binding.annotation.XMLRootElement. The look up is failing because the part being passed to the generator is not the correct case.

The part being passed to the generator looks like this is the debugger:
Instance of: org.eclipse.edt.mof.egl.AnnotationType - eglx.xml.binding.Annotation.XMLRootElement


The problem is the package is not correct: eglx.xml.binding.Annotation.XMLRootElement the A in annotation is capitalized, but the actual package is lower case.

The error appears to be when the IR is created:
<AnnotationType ID="1" eClass="org.eclipse.edt.mof.egl.AnnotationType" isAbstract="false" isInterface="false" name="XMLRootElement" hasCompileErrors="false" packageName="eglx.xml.binding.Annotation" >
Comment 2 Paul Harmon CLA 2011-08-23 13:14:05 EDT
I have updated EGL2MofPart so that all parts are saved with the package names converted to lowercase. I have recompiled all the system parts with this change as well.
Comment 3 Kathy Carroll CLA 2011-08-24 09:42:31 EDT
verified
Comment 4 Lisa Lasher CLA 2011-10-11 16:01:40 EDT
Closing this defect.