Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RestEasy: Could not find MessageBodyWriter for response object of type: java.util.ArrayList of media type: application/json

message: Could not find MessageBodyWriter for response object of type: java.util.ArrayList of media type: application/json

Description: The server encountered an internal error (Could not find MessageBodyWriter for response object of type: java.util.ArrayList of media type: application/json) that prevented it from fulfilling this request

@GET
@Path("/{userName}/questions")
//@Produces("application/json")
public Response getUserQuestions(@PathParam("userName") String userName){               
    UserDAO userDAO = new UserDAO();        
    List<Question> questions = userDAO.getUserQuestionsByUserName(userName);        
    GenericEntity<List<Question>> entity = new GenericEntity<List<Question>>(questions){};      
    return Response.status(200).entity(entity).type(MediaType.APPLICATION_JSON).build();
}

I have got the resteasy jackson provider in the classpath. Tried changing the return type form ArrayList to List, then wrapping it in GenericEntity based on resteasy response, but still getting the same issue.

Running on tomcat7.

Thanks.

like image 849
Balaji Krishnan Avatar asked Sep 30 '13 08:09

Balaji Krishnan


1 Answers

I solved this exception by adding resteasy-jackson-provider.jar to classpath Refer https://bitbucket.org/arcbees/gaestudio/issue/2/need-resteasy-jackson-provider-on

like image 116
Hemanth Avatar answered Oct 23 '22 20:10

Hemanth