title: Marshaling / Demarshaling JSON with Java EE 7 / Glassfish 4.1 results in null object
body: <p>I upgraded to Java EE 7 from Java EE 6 and some of my REST services stopped working.  Narrowing it down, it appears this change seems to have come about when Jersey switched from Jackson to MOXy in Java EE 7.</p>
  
  <p>My service looks like:</p>
  
  <pre><code>@Stateless
  @Path("access")
  public class AccessFacadeREST extends AbstractFacade&lt;Access&gt; {
      @PersistenceContext(unitName = "AccessServerPU")
      private EntityManager em;
  
      public AccessFacadeREST() {
          super(Access.class);
      }
  
      @POST
      @Consumes({"application/xml", "application/json"})
      @Produces({"application/xml", "application/json"})
      public ObjectResponse create(@Context HttpServletRequest requestContext,
                                   @Context SecurityContext context,
                                   ObjectRequest&lt;Access&gt; req) {
          req.setHostname(requestContext.getRemoteAddr());
          return AccessValidation.create(em, req);
      }
  }
  </code></pre>
  
  <p>Here <code>req</code> is null and so generates a <code>NullPointerException</code> when it is presented using JSON.  It works fine when presented as XML.  <code>ObjectRequest</code> is a generic class I use to wrap the request with authentication content standard for several different types of requests.</p>
  
  <p>I tested a similar <code>@GET</code> service to return an <code>ObjectRequest&lt;Access&gt;</code> instance filled with junk data.  It again works well when using XML, but returns <code>null</code> (with no exception raised) when I attempt to return JSON. </p>
  
  <p>I found <a href="https://stackoverflow.com/questions/22781619/java-ee7-rest-server-no-longer-returning-liststring-as-json">Java EE7 REST server no longer returning List as JSON</a>  useful to understand the underlying problem, but didn't see how I could get this to work in my situation.  My <code>ApplicationConfig</code> class looks like:</p>
  
  <pre><code>@javax.ws.rs.ApplicationPath("webresources")
  public class ApplicationConfig extends Application {
  
      @Override
      public Set&lt;Object&gt; getSingletons() {
          Set&lt;Object&gt; set = new HashSet&lt;&gt;();
          log.info("Enabling custom Jackson JSON provider");
          set.add(new JacksonJsonProvider());
          return set;
      }
  
      @Override
      public Map&lt;String, Object&gt; getProperties() {
          Map&lt;String, Object&gt; map = new HashMap&lt;&gt;();
          log.info("Disabling MOXy JSON provider");
          map.put("jersey.config.disableMoxyJson.server", true);
          return map;
      }
  
      @Override
      public Set&lt;Class&lt;?&gt;&gt; getClasses() {
          Set&lt;Class&lt;?&gt;&gt; resources = new java.util.HashSet&lt;&gt;();
          addRestResourceClasses(resources);
          return resources;
      }
  
      private void addRestResourceClasses(Set&lt;Class&lt;?&gt;&gt; resources) {
          resources.add(AccessFacadeREST.class);
      }
  }
  </code></pre>
  
  <p>I think I need to configure the ApplicationConfig class to use Jackson, but I don't see how to generalize the solutions I've found to cover my situation.  So, two questions really:</p>
  
  <ol>
  <li>Have I properly characterized the underlying problem as being some sort of deficiency with MOXy?</li>
  <li>How can I fix this using either MOXy or Jackson (I don't have a preference which, just as long as it works)?</li>
  </ol>
  
  <p>Setup:</p>
  
  <ul>
  <li>Netbeans 8.0.2</li>
  <li>Glassfish 4.1</li>
  <li>JDK 8 / JRE 8U25 (64 bit)</li>
  </ul>
  
  <p><strong>Edit</strong> in response to the question below...</p>
  
  <p>The project <code>pom.xml</code> has the following entry:</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.4.4&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>