0

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',
});
Jeff Storey
  • 56,312
  • 72
  • 233
  • 406
  • 1
    have you seen this question? http://stackoverflow.com/questions/12179737/jersey-json-media-type-application-json-was-not-found it might help – keune Jan 12 '13 at 16:37
  • I'm currently using jersey 1.15, so I think this might be a different issue, but thanks. – Jeff Storey Jan 12 '13 at 16:43

1 Answers1

1

I was missing a dependency on jersey-json.

Jeff Storey
  • 56,312
  • 72
  • 233
  • 406