Community
Participate
Working Groups
Build Identifier: Eclipse Persistence Services - 2.3.0.v20110225-r9029 If you have a domain object that has a field of a type which does not have a zero argument constructor then you will get the exception for this class even if you have XmlAccessorType.NONE and the field is not mapped or annotated. It seems like MOXy is introspecting the domain objects deeply and trying to construct everything even if the members are not needed (due to being transient). I have attached a sample of the code that will reproduce the problem. In the class Bar, if there is no zero argument constructor then the marshalling will not work. You can uncomment the empty constructor to see that it will work in that case. Note that in my oxm.xml file I have only mapped "field1" and not "bar", so there should be no reason for the Bar class to be referenced or instantiated. package com.test; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @XmlAccessorType(XmlAccessType.NONE) public class Bar { // public Bar(){} public Bar(String value){} } package com.test; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlTransient; @XmlAccessorType(XmlAccessType.NONE) public class Foo { private String field1; private String field2; @XmlTransient private Bar bar; public Foo(String string){} public String getField1() { return field1; } public void setField1(String field1) { this.field1 = field1; } public String getField2() { return field2; } public void setField2(String field2) { this.field2 = field2; } public Bar getBar() { return bar; } public void setBar(Bar bar) { this.bar = bar; } } <?xml version="1.0"?> <xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" version="2.1"> <java-types> <java-type name="com.test.Foo" xml-accessor-type="NONE"> <java-attributes> <xml-element java-attribute="field" /> </java-attributes> </java-type> </java-types> </xml-bindings> Reproducible: Always
Created attachment 190045 [details] test case This is a test case which exhibits the bug.
Created attachment 190302 [details] Propsed Fix and Updated Tests
Attached patch checked in to SVN Reviewed by Blaise Doughan
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink