I want to be able to add a new header to my response. I am getting the error:
org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor aroundWriteTo SEVERE: MessageBodyWriter not found for media type=application/json, type=class java.util.ArrayList, genericType=class java.util.ArrayList.
My code is as follows:
@GET
@Path("/persons")
@Produces({ MediaType.APPLICATION_JSON })
public Response getPersons()
{
List<Person> persons = new ArrayList<Person>();
persons.add(new Person(1, "John Smith"));
persons.add(new Person(2, "Jane Smith"));
return Response.ok(persons).build();
}
When I use "List" as the return type and return "persons", there is a successful return, but when I return a "Response" I get the error. How do I get rid of this?