I have a Jersey controller that is returning a List<MyPojo>
(it is actually returning an ArrayList
. My pom includes jersey-server
and so I am automatically getting jersey-media-jaxb
and I have verified that my war does contain that dependency.
The endpoint is marked with:
@Produces(value={MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
When I hit it with no accept
specified (or with application/json
) I get back JSON with no issues. But when I specify 'accept=application/xml` I get:
MessageBodyWriter not found for media type=application/xml, type=class java.util.ArrayList, genericType=java.util.List<MyPoJo>
Not sure if it matters, but I am using Spring boot but I am not using the jersey starter due to version issues.
Update
As a note: this worked using Spring MVC and the default output was XML.
I can't copy/paste the method but here is outline Method:
@Get
@Path("/since")
@Produces(value={MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public List<MyMetadata> since(){
return callService(paramaters);
}
// The below pre-existed me
public class MyMetadata{
private String id;
@JsonSerialize(using=DateTimeSerializer.class)
@JsonDeserialize(using=MyDateTimeDeserializer.class)
private DateTime startTime;
private List<String> ids;
private List<OtherPojo> uuids;
private SecurityPojo security;
private Set<MyTuples> ads;
}