3 Replies Latest reply on Nov 12, 2019 2:49 AM by nitin.shukla

    org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: <MyClass> of media type: application/json

    nitin.shukla

      Hello,

       

      I have a developed Rest service using RESTEasy framework and it works fine when I am returning XML response from my Rest controller. However I want to switch to JSON response and this is where I get the below error:

       

      org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: com.aviseurope.rm.ws.carsintegration.openpricingprogram.domain.OpenPricingProgramResponse of media type: application/json

       

      In my application I initially had following jars:

      • resteasy-spring-3.1.4.Final.jar
      • resteasy-jaxrs-3.1.4.Final.jar
      • resteasy-jaxb-provider-3.1.4.Final.jar

       

      When switching to json format response I have now added below jar:

      • resteasy-jackson-provider-3.1.4.Final.jar

       

      Even after adding the resteasy-jacksom-provider jar. I continue to get the same error as mentioned above.

       

      Am I missing anything here to get this to work to return JSON format response instead of XML? In my rest method I have kept below annotation:

       

      @Get

      @Produces(MeditaType.APPLICATION_JSON)

      @Path("/countriesAndPPs")

      public Response getCountryAndPricingProgram(@Context HttpServletRequest request)

      {

      ...

      }

       

      Switching back to @Produces(MeditaType.APPLICATION_XML) works fine and I get the xml response as expected. My web application is hosted on JBOSS EAP 7.0.8.GA.

       

      Appreciate any help to resolve the above issue. Thank you.