Relaxation reaction

I have a similar case described here: Dynamically changing the return type of a RESTEasy service

The problem I am facing is that I am trying to return a list of objects (annotated using @XMLRootEntity ), but I get an error code on 500 servers:

The server detected an internal error (could not find a MessageBodyWriter for the response object of type: java.util.ArrayList media type: application / json), which prevented it from executing this request.

Can you give some tips on how to solve this problem?

I'm not sure where to look.

Thanks.

0
java rest web-services tomcat7
source share
1 answer

Instead of using a list implementation, you should use an interface.

Try changing the return type with: java.util.List

EDIT: Try wrapping the list in GenericEntity :

 List<String> myList = new ArrayList<String>(); // add ... final GenericEntity<List<String>> entity = new GenericEntity<List<String>>(myList) { }; Response.status(Status.BAD_REQUEST).entity(entity).build(); 
+8
source share

All Articles