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

10,672

How do you deploy your application? What application server do you use? What version of RestEasy? What RestEasy configuration have you specified(in web.xml or Application class)? Resteasy relies on providers for serialization/deserialization of objects. These providers need to contained in the classpath of your JAX-RS application. Depending on your build, application packaging and runtime environment these providers might be missing. Furthermore, discovery of providres can be configured, e.g. automatically discover all privoders in classpath, or only use those explicitly mentioned in conf. Commonly used providers with application/json capabilities are resteasy-jackson-provider, resteasy-jettison-provider. Verify that at least one of these is available in your classpath.

Share:
10,672

Related videos on Youtube

tun_eng
Author by

tun_eng

Updated on July 11, 2022

Comments

  • tun_eng
    tun_eng almost 2 years

    I have this REST service that returns JSON code :

    @GET
    @Path("/mypath")
    @Produces(MediaType.APPLICATION_JSON)
    public Response getS() {
        Map<String, String> map = new LinkedHashMap<String, String>();
    
        map.put(key1, val1);
        map.put(key2, val2);
    
        return Response.ok(map, MediaType.APPLICATION_JSON).build();
    }
    

    This service is deployed in a Tomcat server. I am using RESTeasy as framework. When trying to access the service, I encounter this:

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

    I didn't understand what is the problem.

    Thanks in advance

    • tun_eng
      tun_eng over 11 years
      I resolved the problem in Tomcat by the modifications that I found in this link. The author wrote how he had recovered a map in JSON. But I encounter always the same problem in JBOSS