Skip to content
Advertisement

Could not find MessageBodyWriter for response object of type: java.util.ArrayList of media type: text/html – in Resteasy

I am developing RESTEasy Example. In this example I am using all latest dependencies and deploying om tomcat 8.x version. I can successfully deploy the application but when I am launching the url: http://localhost:8080/RESTfulExample/rest/restwebservice/list, I see following errors are coming. Please guide what is going wrong here.

JavaScript

The code I developed so far for reference: pom.xml

JavaScript

Student.java

JavaScript

RESTEasyService.java

JavaScript

RESTWebServiceJavaExample.java

JavaScript

web.xml:

JavaScript

Advertisement

Answer

Now I am able to solve this issue. I need to add following dependency in pom.xml:

JavaScript

And 1) I should be using @Produces(MediaType.APPLICATION_XML) on method signature to get following response.

JavaScript
  1. If you want to use @Produces(MediaType.TEXT_PLAIN) then code will gives you following output which doesn’t looks useful.

    [com.mkyong.rest.Student@4d5fd75e, com.mkyong.rest.Student@7715574d]

So use 1) solution.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement