title: A message body writer for Java class java.util.ArrayList, and Java type class java.util.ArrayList, and MIME media type application/json was not found
body: <p>I am new to using jersy for implementing rest api</p>
  
  <p>I get the below error, when I call the products service.</p>
  
  <pre><code> com.sun.jersey.api.MessageException: A message body writer for Java class java.util.ArrayList, and Java type class java.util.ArrayList, and MIME media type application/json was not found.
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>@GET
  @Path("/products")
  @Produces(MediaType.APPLICATION_JSON)
  public Response productSearch(@QueryParam("name") String name)
  {
     List&lt;Product&gt; products = new ArrayList&lt;&gt;();
     products.add(new Product("PRDNAME", "PRDCOST", "PRDMODEL"));
     return Response.ok( products).build();
  }
  </code></pre>
  
  <p>I also tried this:</p>
  
  <pre><code>@GET
  @Path("/products")
  @Produces(MediaType.APPLICATION_JSON)
  public List&lt;Product&gt; productSearch(@QueryParam("name") String name)
  {
     List&lt;Product&gt; products = new ArrayList&lt;&gt;();
     products.add(new Product("PRDNAME", "PRDCOST", "PRDMODEL"));
     return products;
  }
  </code></pre>
  
  <p>The below is the setup of my environment:</p>
  
  <ul>
  <li>Tomcat 8,  </li>
  <li>Jersey libraries: jersey-bundle-1.19.1,  </li>
  <li>Not using maven</li>
  </ul>
  
  <p>web.xml:</p>
  
  <pre><code>    &lt;servlet&gt;
          &lt;servlet-name&gt;jersey-serlvet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
              &lt;param-value&gt;org.test.rest&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-serlvet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>I tried using the below init-param also:</p>
  
  <pre><code>    &lt;init-param&gt;  
        &lt;param-name&gt;com.sun.jersey.api.json.POJOMappingFeature&lt;/param-name&gt;  
        &lt;param-value&gt;true&lt;/param-value&gt;  
      &lt;/init-param&gt;
  </code></pre>
  
  <p>I tried returning GenericEntity, but had the same issue.</p>
  
  <pre><code>return Response.ok().entity(new GenericEntity&lt;List&lt;Product&gt;&gt;(products) {}).build();
  </code></pre>
  
  <p>I also tried using </p>
  
  <ul>
  <li>jersey-core-1.8.jar </li>
  <li>jersey-json-1.8.jar </li>
  <li>jersey-server-1.8.jar</li>
  </ul>
  
  <p>instead of jersey-bundle-1.19.1</p>
  
  <p>I don't have any issues when I return string. 
  I understand, I am missing the json media type dependency, but could not figure it out.</p>
  
  <p>This error happens on the tomcat server while the client doesn't receive response obviously.</p>