title: Resteasy and Jackson ignoring JAXB annotations
body: <p>I am in the process of converting an Ant RestEasy project to Maven.  I have most everything up an running again, with one problem.  The JSON output is not working like it did before.  For example, here is a simple entity which gets output:</p>
  
  <pre><code>import javax.xml.bind.annotation.XmlElement;
  import javax.xml.bind.annotation.XmlRootElement;
  
  @XmlRootElement(name = "site-recode")
  public class SiteRecode {
      @XmlElement(name = "site", required = true)
      protected String _site;
      @XmlElement(name = "hist", required = true)
      protected String _hist;
      @XmlElement(name = "ks_and_meso", required = true)
      protected Boolean _withKsAndMeso;
      @XmlElement(name = "site-group", required = true)
      protected String _siteGroup;
  
      public SiteRecode() {
      }
  
      public SiteRecode(String site, String hist, Boolean withKsAndMeso, String siteGroup) {
          this._site = site;
          this._hist = hist;
          this._withKsAndMeso = withKsAndMeso == null ? Boolean.TRUE : withKsAndMeso;
          this._siteGroup = siteGroup;
      }
  
  }
  </code></pre>
  
  <p>and here is the context resolver I use for RestEasy:</p>
  
  <pre><code>@Provider
  @Produces(MediaType.APPLICATION_JSON)
  public class JacksonContextResolver implements ContextResolver&lt;ObjectMapper&gt; {
  
      private ObjectMapper _objectMapper;
  
      public JacksonContextResolver() {
          _objectMapper = new ObjectMapper();
          _objectMapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
      }
  
      public ObjectMapper getContext(Class&lt;?&gt; objectType) {
          return _objectMapper;
      }
  }
  </code></pre>
  
  <p>Under our old Ant builds both JSON and XML output worked great.  XML output still works perfectly.  Now I get this exception if I try to get JSON:</p>
  
  <blockquote>
    <p>Caused by: org.codehaus.jackson.map.JsonMappingException: No serializer found for class com.imsweb.seerapi.siterecode.SiteRecode and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) )</p>
  </blockquote>
  
  <p>I've found out 2 things. </p>
  
  <ul>
  <li>If I change the fields from protected to public I get output.  However the names are wrong (ignoring the names in the annotations):</li>
  </ul>
  
  <p><code>{
      "_hist": "9650",
      "_site": "C379",
      "_siteGroup": "33011",
      "_withKsAndMeso": true
  }</code></p>
  
  <ul>
  <li>Another thing that kind of works is adding getters and setters and moving the @XmlElement annotations to there.  I don't get the exception anymore, but the names are based on method names and not annotations:</li>
  </ul>
  
  <p><code>{
      "hist": "9650",
      "site": "C379",
      "siteGroup": "33011",
      "withKsAndMeso": true
  }</code></p>
  
  <p>So basically it is completely ignoring my annotations.  It will show the default named fields/methods if they are public.</p>
  
  <p>However the XML output still works perfectly and honors the annotation names:</p>
  
  <pre><code>&lt;site-recode&gt;
      &lt;site&gt;C379&lt;/site&gt;
      &lt;hist&gt;9650&lt;/hist&gt;
      &lt;ks_and_meso&gt;true&lt;/ks_and_meso&gt;
      &lt;site-group&gt;33011&lt;/site-group&gt;
  &lt;/site-recode&gt;
  </code></pre>
  
  <p>I've Looked at the produced WAR files from both Ant and Maven and I can't figure out what I am doing differently.  Has anyone seen something like this?  Thanks.</p>
  
  <p>Update:</p>
  
  <p>I figured it out.  I had forgot to set up the manifest correctly in the pom.xml.  I just need to add:</p>
  
  <pre><code>&lt;manifestEntries&gt;
       &lt;Dependencies&gt;org.codehaus.jackson.jackson-xc,org.codehaus.jackson.jackson-mapper-asl,org.codehaus.jackson.jackson-core-asl,org.apache.commons.logging export,org.apache.log4j export&lt;/Dependencies&gt;
  &lt;/manifestEntries&gt;
  </code></pre>