title: "MessageBodyWriter not found" when returning List<Long> with the Response-object in JAX-RS
body: <p>I am currently trying to create a rest-webservice which returns an object of the type <em>List&lt; Long></em>. The service is annotated with <em>@Produces(MediaType.APPLICATION_JSON)</em>.</p>
  
  <p>I don't have any problems with the other services in this project.</p>
  
  <p>If I write the code as following:</p>
  
  <pre><code>List&lt;Long&gt; list = new ArrayList&lt;Long&gt;();
              list.add(100L);
              list.add(200L);
              list.add(300L);
  
  return Response.ok(list)
                 .build();
  </code></pre>
  
  <p>Then I get the following message in the log:                           </p>
  
  <pre><code>MessageBodyWriter not found for media type=application/json, type=class java.util.ArrayList, genericType=class java.util.ArrayList.
  </code></pre>
  
  <p>If I instead write it as following (same as I did for another service in the project, but where it is a List of pojo objects):</p>
  
  <pre><code>List&lt;Long&gt; list = new ArrayList&lt;Long&gt;();
              list.add(100L);
              list.add(200L);
              list.add(300L);
  
  GenericEntity&lt;List&lt;Long&gt;&gt; genericEntity = new GenericEntity&lt;List&lt;Long&gt;&gt;(list){};
  
  return Response.ok(genericEntity)
                 .build();
  </code></pre>
  
  <p>Then I get the following message instead:</p>
  
  <pre><code>MessageBodyWriter not found for media type=application/json, type=class java.util.ArrayList, genericType=java.util.List&lt;java.lang.Long&gt;.
  </code></pre>
  
  <p>After googling I found the following suggestion to convert the List to an array as seen below, but this didn't work either.</p>
  
  <pre><code>List&lt;Long&gt; list = new ArrayList&lt;Long&gt;();
              list.add(100L);
              list.add(200L);
              list.add(300L);
  
              return Response.ok(list.toArray()).build();
  </code></pre>
  
  <p>Then I get:</p>
  
  <pre><code>MessageBodyWriter not found for media type=application/json, type=class [Ljava.lang.Object;, genericType=class [Ljava.lang.Object;.
  </code></pre>
  
  <p>We are using jackson-core version 2.3.2 and the jax-rs implementation is Jersey which is included with Weblogic 12c.</p>
  
  <p>Is there any good solution for this (without using any other libraries)?</p>