I have a Jersey web service that consumes a json array and tries to convert it to a list. I'm getting the following error:
SEVERE: A message body reader for Java class java.util.List, and Java type java.util.List, and MIME media type application/json was not found.
Can someone explain why?
I have posted the relevant code snippets
Jersery service
@POST
@Consumes(MediaType.APPLICATION_JSON)
public void run(List<Person> people) {
// do something with people
}
Person class
@XmlRootElement
public class Person {
String first;
String last;
// constructors
}
json
{"people":[ {"first":"Bob","last":"Jones"}, {"first":"Bill","last":"Smith"} ] }
jquery posting
$.ajax({
type: 'POST',
url: 'myurl',
data: data,
contentType: 'application/json',
dataType: 'application/json',
});