Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-1180

3.0.11.Final and 3.0.9.Final: NoMessageBodyWriterFoundFailure

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major Major
    • None
    • 3.0.9.Final, 3.0.11.Final
    • jaxrs
    • Documentation (Ref Guide, User Guide, etc.), User Experience

      org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: [Lmodels.Person; of media type: application/json
      at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:67)
      ------------------------
      curl http://localhost:8080/mrs/api/persons
      Could not find MessageBodyWriter for response object of type: [Lresteasysample.jaxrs.Person; of media type: application/json
      -----------------

      @Path("/persons")
      public class PersonController {
      ...
      List<Person> persons = Arrays.asList(
      new Person("Speed Light"),
      new Person("Slow Snail"),
      new Person("Water Flow"));

      @GET
      @Consumes(

      {"application/json", "application/xml"})
      @Produces({"application/json", "application/xml"}

      )
      public Person[] get()

      { return return persons.toArray(new Person[0]); }

      }

      XmlRootElement(name = "Person")
      public class Person {

      private static int count = 1;

      private String pid;
      private String name;
      private boolean sex = false;
      private int age;

      public Person() {
      }

      public Person(String name)

      { this.name = name; pid = "" + count; age = Integer.parseInt(count + "" + count); count++; }

      @XmlElement
      public String getName()

      { return name; }

      ... // other setters getters
      }

      ------------
      I have also posted the same issue here:
      http://stackoverflow.com/questions/30616954/resteasy-3-0-9-final-nomessagebodywriterfoundfailure

            rsigal@redhat.com Ronald Sigal
            ongbp_jira Ong Boon Pang (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: