title: How do I return a List<String> from Rest call
body: <p>I'm trying to return a List in a few different media types.  I'm hosting this on glassfish 4.</p>
  
  <pre><code>@GET
  @Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN})
  public List&lt;String&gt; getSessions(){
      return Arrays.asList("foo","bar");
  }
  </code></pre>
  
  <p>If I do a plain GET without specifying the type, I get a 500 internal server error.  Specifying application/json also gives me a 500 internal server error.  The server log shows absolutely no errors.</p>
  
  <p>If I do a GET with Accept: text/plain, I get the following:</p>
  
  <blockquote>
    <p>org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException:
    MessageBodyWriter not found for media type=text/plain, type=class
    java.util.Arrays$ArrayList,
    genericType=java.util.List.</p>
  </blockquote>
  
  <p>I would have thought glassfish could figure out what to do with basic collection classes here.  They silently fail when I try to parse them into json and apparently don't have a messagebodywriter to turn them into strings.  Am I missing something obvious?</p>
  
  <p><strong>Update</strong>
  I've added Jackson as a jaxrs json provider using the instructions here:
  <a href="https://github.com/FasterXML/jackson-jaxrs-providers" rel="nofollow">https://github.com/FasterXML/jackson-jaxrs-providers</a></p>
  
  <p>Apparently with the current release, I do not need to specifically register JacksonFeature.class, nor am I able to, because there is no JacksonFeature class, just a JacksonFeatures interface.</p>
  
  <p>I added this dependency to my project:</p>
  
  <pre><code>&lt;dependency&gt;
    &lt;groupId&gt;com.fasterxml.jackson.jaxrs&lt;/groupId&gt;
    &lt;artifactId&gt;jackson-jaxrs-json-provider&lt;/artifactId&gt;
    &lt;version&gt;2.3.0&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>I am now able to return json if I do so through a Response object as follows:</p>
  
  <pre><code>@GET
  @Produces(MediaType.APPLICATION_JSON)
  public Response getSessions(){
      Response r = Response.ok(Arrays.asList("foo","bar")).build();
      return r;
  }
  </code></pre>
  
  <p>However, attempting to return List still fails with a 500 internal server error and no message to the server error log.</p>
  
  <p>I'm willing to use the Response method if this is the correct approach, but it seems like the other way should work.</p>