title: MessageBodyWriter not found vogella tutorial
body: <p>I am attempting to recreate the most excellent vogella tutorial for create REST with java, JAX-RS and Jersey. </p>
  
  <p>I'm using eclipse Kepler with Java-EE perspective, tomcat 7.0. </p>
  
  <p>I have create the Todo class, the TodoResource class with the appropriate annotations and deployed on tomcat 7. I have imported the jaxrs-ri libs into the WEB-INF/lib folder as instructed. </p>
  
  <p>Todo class:</p>
  
  <pre><code>package com.vogella.jersey.jaxb.model;
  
  import javax.xml.bind.annotation.XmlRootElement;
  
  @XmlRootElement
  public class Todo {
    private String summary;
    private String description;
    public String getSummary() {
      return summary;
    }
    public void setSummary(String summary) {
      this.summary = summary;
    }
    public String getDescription() {
      return description;
    }
    public void setDescription(String description) {
      this.description = description;
    }
  
  
  } 
  </code></pre>
  
  <p>TodoResource with annotations:</p>
  
  <pre><code>package com.vogella.jersey.jaxb.model;
  
  import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  
  @Path("/todo")
  public class TodoResource {
    // This method is called if XMLis request
    @GET
    @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
    public Todo getXML() {
      Todo todo = new Todo();
      todo.setSummary("This is my first todo");
      todo.setDescription("This is my first todo");
      return todo;
    }
  
    // This can be used to test the integration with the browser
    @GET
    @Produces({ MediaType.TEXT_XML })
    public Todo getHTML() {
      Todo todo = new Todo();
      todo.setSummary("This is my first Todo");
      todo.setDescription("This is my first Todo");
      return todo;
    }
  
  }
  </code></pre>
  
  <p>web.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"&gt;
    &lt;display-name&gt;com.vogella.jersey.first&lt;/display-name&gt;
    &lt;servlet&gt;
      &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;/servlet-class&gt;
      &lt;init-param&gt;
        &lt;param-name&gt;jersey.config.server.provider.packages&lt;/param-name&gt;
        &lt;param-value&gt;com.vogella.jersey.jaxb&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>I have also created the client as instructed. </p>
  
  <p>Test.java:</p>
  
  <pre><code>package com.vogella.jersey.first.client;
  
  import java.net.URI;
  import javax.ws.rs.client.Client;
  import javax.ws.rs.client.ClientBuilder;
  import javax.ws.rs.client.WebTarget;
  import javax.ws.rs.core.MediaType;
  import javax.ws.rs.core.Response;
  import javax.ws.rs.core.UriBuilder;
  
  import org.glassfish.jersey.client.ClientConfig;
  import org.glassfish.jersey.client.ClientResponse;
  import org.glassfish.jersey.message.internal.MediaTypes;
  
  public class Test {
  
    public static void main(String[] args) {
  
  
  
      ClientConfig config = new ClientConfig();
  
      Client client = ClientBuilder.newClient(config);
  
      WebTarget target = client.target(getBaseURI());
  
  
      System.out.println(target.path("rest").path("todo").request()
  
              .accept(MediaType.APPLICATION_XML ).get(Response.class)
  
              .toString());
  
      System.out.println(target.path("rest").path("todo").request()
  
              .accept(MediaType.APPLICATION_JSON ).get(Response.class)
  
              .toString());
  
  
    }
  
    private static URI getBaseURI() {
  
        return UriBuilder.fromUri("http://localhost:8080/com.vogella.jersey.jaxb").build();
  
    }
  }
  </code></pre>
  
  <p>Everything works perfectly for the MediaType.APPLICATION_XML - the server returns:</p>
  
  <pre><code>InboundJaxrsResponse{ClientResponse{method=GET, uri=http://localhost:8080/com.vogella.jersey.jaxb/rest/todo, status=200, reason=OK}}
  </code></pre>
  
  <p>However, for the MediaType APPLICATION_JSON - which is what I actually need, I get an error:</p>
  
  <pre><code>InboundJaxrsResponse{ClientResponse{method=GET, uri=http://localhost:8080/com.vogella.jersey.jaxb/rest/todo, status=500, reason=Internal Server Error}}
  </code></pre>
  
  <p>Tomcat clearly shows me the problem - it seems to me it doesn't know how to return a JSON response - </p>
  
  <pre><code>Nov 02, 2014 11:59:19 AM org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor aroundWriteTo
  SEVERE: MessageBodyWriter not found for media type=application/json, type=class com.vogella.jersey.jaxb.model.Todo, genericType=class com.vogella.jersey.jaxb.model.Todo.
  </code></pre>
  
  <p>My understanding is that the jaxrs-ri 2.13 bundle includes everything required including dependencies to let me do this - and that I don't need to add any kind of JSON provider. I have done so anyway, I have tried adding gson for example,  I have downloaded the moxy jars and attempting to add them to my WEB-INF/lib folder and deploy - all to no avail. I don't know if I'm completely out in the weeds, or if I'm missing something simple?</p>