I am declaring a List object property with:
@XmlRootElement(namespace = "...")
@XmlType
public class Test {
private List<String> myList;
@XmlElementWrapper(name = "myListWrapper")
@XmlElement(name = "myList")
public List<String> getMyList() {
return myList;
}
}
When an instance of this class with an empty list myList
is marshalled, MOXy is not generating an empty wrapper MyListWrapper
. However, JAXB RI would do it. The generated XML looks like this when using the RI:
<ns2:test xmlns:ns2="...">
<myListWrapper/>
</ns2:intensionalSet>
Is there a way to obtain the same result with MOXy?
Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB 2 (JSR-222) expert group.
This is a bug in the MOXy implementation of JAXB. You can use the following link to track this issue: