title: Use Jackson as JAXB-JSON-processor in JavaEE Application
body: <p>I've seen many articles and SO-questions about this - but I just don't get it working.
  My goal is to use Jackson as JSON processor in a JavaEE application. What do I have so far?</p>
  
  <h2>pom.xml</h2>
  
  <ul>
  <li><p>either this one</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;
      &lt;artifactId&gt;jersey-media-json-jackson&lt;/artifactId&gt;
      &lt;version&gt;2.17&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre></li>
  <li><p>or this one (which of them is correct in the end?)</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.5.2&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre></li>
  <li><p>plus this (due to <a href="http://blog.dejavu.sk/2015/03/24/what-to-do-when-jax-rs-cannot-find-its-providers-aka-my-message-body-writer-is-not-used/?utm_source=jersey&amp;utm_medium=home&amp;utm_campaign=latest" rel="nofollow">this article</a>, because auto discovery shall not exist in jackson packages anymore):</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.glassfish.jersey.ext&lt;/groupId&gt;
      &lt;artifactId&gt;jersey-metainf-services&lt;/artifactId&gt;
      &lt;version&gt;2.17&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre></li>
  </ul>
  
  <h2>web.xml</h2>
  
  <p>Simple REST registration:</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;javax.ws.rs.core.Application&lt;/servlet-name&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;javax.ws.rs.core.Application&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <h2>A simple Object</h2>
  
  <pre><code>import com.fasterxml.jackson.annotation.JsonProperty;
  
  public class Dummy {
      private String name;
  
      @JsonProperty("username")
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  }
  </code></pre>
  
  <h2>The REST resource</h2>
  
  <pre><code>@GET
  @Path("test")
  @Produces(MediaType.APPLICATION_JSON)
  public Response getRequest() {
      Dummy dummy = new Dummy();
      dummy.setName("rolf");
  
      return Response.ok(dummy).build();
  }
  </code></pre>
  
  <hr>
  
  <p>And the output is</p>
  
  <pre><code>{"name":"rolf"}
  </code></pre>
  
  <p>instead of the expected</p>
  
  <pre><code>{"username":"rolf"}
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>I'm using the GlassFish application server.</p>