title: JAX-RS JAXB Jackson not using @XmlRootElement name
body: <p>I am developing a restful application with JAX-RS and JAXB. I want to send following Entity as JSON to my client:</p>
  
  <pre class="lang-java prettyprint-override"><code>@XmlRootElement(name = "user")
  @XmlAccessorType(XmlAccessType.FIELD)
  public class UserDTO implements Serializable
  {
      private static final long serialVersionUID = 1L;
  
      private Long id;
      private String username;
      private String firstname;
      private String lastname;
  
      // getter &amp; setter
  }
  </code></pre>
  
  <p>The method in my WebService is defined as follows:</p>
  
  <pre class="lang-java prettyprint-override"><code>@POST
  @Path("users/{id}")
  @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
  public UserAccountDTO login(@PathParam("id") Long id)
  {
      UserAccountDTO userAccount = loadUserAccount(id);
      return userAccount;
  }
  </code></pre>
  
  <p>First problem was, that the root node was not send via JSON. Therefore I have added following Class:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Provider
  @Produces(MediaType.APPLICATION_JSON)
  public class SkedFlexContextResolver implements ContextResolver&lt;ObjectMapper&gt;
  {
      private ObjectMapper objectMapper;
  
      public SkedFlexContextResolver() throws Exception
      {
          this.objectMapper = new ObjectMapper().configure(SerializationFeature.WRAP_ROOT_VALUE, true);
      }
  
      @Override
      public ObjectMapper getContext(Class&lt;?&gt; objectType)
      {
          return objectMapper;
      }
  }
  </code></pre>
  
  <p>Now, the root node is send with the data. In case of XML everything is fine (root node is equal to name of <code>@XmlRootElement</code>). See following XML response:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;user&gt;
    &lt;id&gt;10&lt;/id&gt;
    &lt;username&gt;Admin&lt;/username&gt;
    &lt;firstname&gt;Administrator&lt;/firstname&gt;
  &lt;/user&gt;
  </code></pre>
  
  <p>But in case of JSON the root node is the Classname of the POJO:</p>
  
  <pre class="lang-json prettyprint-override"><code>{
      "UserAccountDTO":
      {
          "id": 10,
          "username": "Admin",
          "firstname": "Administrator",
          "lastname": null
      }
  }
  </code></pre>
  
  <p>Why differs the output between XML and JSON? What do I need to change to get the specified name in the <code>@XmlRootElement</code>-Annotation</p>