I’m using Java Jersey 1.x to marshall an object that has several members, one of which is a list. All member variables are getting marshalled properly and returned with the correct return type. However, it doesn’t include the objectList in the return data.
Example:
@XmlRootElement
public class ClassWithList {
private String front;
private int total;
private ArrayList<AnotherPOJOObject> objectList;
...
getters/setters
Getter:
public List<AnotherPOJOObject> getObjectList() {
return objectList;
}
I debugged it and checked that objectList is indeed populated with data.
AnotherPOJOObject is also annotated as an XmlRootElement
Thanks to the suggestion to basiljames, I was able to get closer to the answer. The real issue was that the List of
AnotherPOJOOjectwasn’t so plain after all. Each object had an untypedMapof it’s own, and that threw the Marshaller into a fit, because, it always wants to know the type of an object.I guess the takeaway from this answer to make sure that every collection you return has a well defined type!