title: MessageBodyWriter not found for media type=application/json when returning JSON in REST web service with Jersey
body: <p>I am trying to create a very simple REST service using Jersey. Here is the service code</p>
  
  <pre class="lang-java prettyprint-override"><code>@Path("/UserService")
  public class UserService {
  
      @GET
      @Path("/users")
      @Produces(MediaType.APPLICATION_XML)
      public List&lt;User&gt; getUsers() {
          User user = new User(1, "Thomas", "Greene");
          List&lt;User&gt; userList = new ArrayList&lt;User&gt;();
          userList.add(user);
          return userList;
      }
  }
  </code></pre>
  
  <p>When I run it through Postman, it returns me a XML response</p>
  
  <p><a href="https://i.stack.imgur.com/gbY1E.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gbY1E.png" alt="XML response in Postman"></a></p>
  
  <p>Now, I want to get a JSON response back. So, I changed the mediatype to <code>application/json</code>:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Path("/UserService")
  public class UserService {
  
      @GET
      @Path("/users")
      @Produces(MediaType.APPLICATION_JSON)
      public List&lt;User&gt; getUsers(){ 
          User user = new User(1, "Thomas", "Greene");
          List&lt;User&gt; userList = new ArrayList&lt;User&gt;();
          userList.add(user);
          return userList;
     }    
  }
  </code></pre>
  
  <p>It gives me the below error in Tomcat logs:</p>
  
  <blockquote>
    <p>SEVERE: MessageBodyWriter not found for media type=application/json, type=class java.util.ArrayList, genericType=java.util.List.</p>
  </blockquote>
  
  <p>Can someone please guide me how to get a JSON response back?</p>