title: Not getting Json results with latest Jackson using jersey 2.22.1
body: <p>I am using jersey v2.21 and I am trying to set my <code>ObjectMapper</code> with couple of configurations:</p>
  
  <ol>
  <li>Don't return a property if its value is <code>null</code></li>
  <li>Return the properties of object ordered alphabetically</li>
  <li>Return dates in a format like this: <code>2015-06-22T17:57:05.000-07:00</code></li>
  </ol>
  
  <p>This how my ObjectMapper looks like:
  <strong>Edited:</strong></p>
  
  <pre><code>import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  import javax.ws.rs.ext.ContextResolver;
  import javax.ws.rs.ext.Provider;
  
  import com.fasterxml.jackson.annotation.JsonInclude;
  import com.fasterxml.jackson.databind.*;
  import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
  import com.fasterxml.jackson.databind.type.TypeFactory;
  import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
  
  /**
   * Created by Shiran Maor on 1/13/16.
   */
  @Provider
  @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
  public class ObjectMapperResolver implements ContextResolver&lt;ObjectMapper&gt; {
  
      private ObjectMapper defaultMapper;
  
      public ObjectMapperResolver() {
          this.defaultMapper = createDefaultMapper();
      }
  
      @Override
      public ObjectMapper getContext(Class&lt;?&gt; aClass) {
          return this.defaultMapper;
      }
  
      private static ObjectMapper createDefaultMapper() {
          ObjectMapper result = new ObjectMapper();
          result = result.configure(SerializationFeature.INDENT_OUTPUT, true);
          result = result.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
          result = result.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
  
          result.setSerializationInclusion(JsonInclude.Include.NON_NULL);
          result.setDateFormat(new ISO8601DateFormat());
  
          return result;
  
      }
  
  }
  </code></pre>
  
  <p><strong>Edit:</strong>
  These are my dependencies:</p>
  
  <pre><code>    &lt;dependency&gt;
        &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt;
        &lt;artifactId&gt;jersey-container-servlet&lt;/artifactId&gt;
        &lt;version&gt;2.22.1&lt;/version&gt;
        &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
      &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.21&lt;/version&gt;
        &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;
        &lt;artifactId&gt;jersey-media-jaxb&lt;/artifactId&gt;
        &lt;version&gt;2.21&lt;/version&gt;
        &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;javax.annotation&lt;/groupId&gt;
        &lt;artifactId&gt;javax.annotation-api&lt;/artifactId&gt;
        &lt;version&gt;1.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;javax.ws.rs&lt;/groupId&gt;
        &lt;artifactId&gt;javax.ws.rs-api&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
        &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
        &lt;version&gt;2.7.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.fasterxml.jackson.module&lt;/groupId&gt;
        &lt;artifactId&gt;jackson-module-jaxb-annotations&lt;/artifactId&gt;
        &lt;version&gt;2.7.0&lt;/version&gt;
        &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
      &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
      &lt;artifactId&gt;jackson-annotations&lt;/artifactId&gt;
      &lt;version&gt;2.7.0&lt;/version&gt;
    &lt;/dependency&gt;
      &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.7.0&lt;/version&gt;
        &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.fasterxml.jackson.jaxrs&lt;/groupId&gt;
        &lt;artifactId&gt;jackson-jaxrs-xml-provider&lt;/artifactId&gt;
        &lt;version&gt;2.7.0&lt;/version&gt;
        &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p><strong>Edit:</strong>
  This is the tree dependencies:</p>
  
  <pre><code>[INFO] +- commons-codec:commons-codec:jar:1.6:compile
  [INFO] +- org.apache.httpcomponents:httpclient:jar:4.1.1:compile
  [INFO] +- org.apache.httpcomponents:httpcore:jar:4.1.1:compile
  [INFO] +- commons-httpclient:commons-httpclient:jar:3.1:runtime
  [INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.7:runtime
  [INFO] +- org.slf4j:jul-to-slf4j:jar:1.7.7:runtime
  [INFO] +- org.slf4j:slf4j-api:jar:1.7.7:compile
  [INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.7:runtime
  [INFO] +- log4j:log4j:jar:1.2.14:compile
  [INFO] +- org.mockito:mockito-all:jar:1.9.5:test
  [INFO] +- org.jasig.cas.client:cas-client-core:jar:3.2.1:compile
  [INFO] +- com.google.code.gson:gson:jar:1.7.1:compile
  [INFO] +- org.testng:testng:jar:6.8.8:test
  [INFO] |  +- org.beanshell:bsh:jar:2.0b4:test
  [INFO] |  \- com.beust:jcommander:jar:1.27:test
  [INFO] +- net.sf.ehcache:ehcache-core:jar:2.4.2:compile
  [INFO] +- commons-cli:commons-cli:jar:1.2:runtime
  [INFO] +- commons-io:commons-io:jar:1.4:compile
  [INFO] +- commons-lang:commons-lang:jar:2.4:compile
  [INFO] +- com.thoughtworks.xstream:xstream:jar:1.2.2:provided
  [INFO] |  \- xpp3:xpp3_min:jar:1.1.4c:provided
  [INFO] +- org.glassfish.jersey.containers:jersey-container-servlet:jar:2.22.1:runtime
  [INFO] |  +- org.glassfish.jersey.containers:jersey-container-servlet-core:jar:2.22.1:runtime
  [INFO] |  +- org.glassfish.jersey.core:jersey-common:jar:2.22.1:runtime
  [INFO] |  |  \- org.glassfish.jersey.bundles.repackaged:jersey-guava:jar:2.22.1:runtime
  [INFO] |  \- org.glassfish.jersey.core:jersey-server:jar:2.22.1:runtime
  [INFO] |     \- org.glassfish.jersey.core:jersey-client:jar:2.22.1:runtime
  [INFO] +- org.glassfish.jersey.media:jersey-media-json-jackson:jar:2.21:runtime
  [INFO] |  +- org.glassfish.jersey.ext:jersey-entity-filtering:jar:2.21:runtime
  [INFO] |  \- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.5.4:runtime
  [INFO] +- org.glassfish.jersey.media:jersey-media-jaxb:jar:2.21:runtime
  [INFO] |  +- org.glassfish.hk2:hk2-api:jar:2.4.0-b31:runtime
  [INFO] |  |  +- org.glassfish.hk2:hk2-utils:jar:2.4.0-b31:runtime
  [INFO] |  |  \- org.glassfish.hk2.external:aopalliance-repackaged:jar:2.4.0-b31:runtime
  [INFO] |  +- org.glassfish.hk2.external:javax.inject:jar:2.4.0-b31:runtime
  [INFO] |  +- org.glassfish.hk2:hk2-locator:jar:2.4.0-b31:runtime
  [INFO] |  |  \- org.javassist:javassist:jar:3.18.1-GA:runtime
  [INFO] |  \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:runtime
  [INFO] +- javax.annotation:javax.annotation-api:jar:1.2:compile
  [INFO] +- javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile
  [INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.7.0:compile
  [INFO] |  \- com.fasterxml.jackson.core:jackson-core:jar:2.4.2:compile
  [INFO] +- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.7.0:runtime
  [INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.7.0:compile
  [INFO] +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.7.0:runtime
  [INFO] +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-xml-provider:jar:2.7.0:runtime
  [INFO] |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:jar:2.7.0:runtime
  [INFO] |  +- org.codehaus.woodstox:stax2-api:jar:3.1.4:runtime
  [INFO] |  \- org.codehaus.woodstox:woodstox-core-asl:jar:4.4.1:runtime
  [INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
  [INFO] +- javax.servlet.jsp:javax.servlet.jsp-api:jar:2.3.1:provided
  [INFO] +- org.apache.httpcomponents:httpmime:jar:4.1.1:test
  [INFO] +- org.bouncycastle:bcprov-jdk15:jar:1.45:test
  [INFO] +- xml-apis:xml-apis:jar:1.4.01:compile
  [INFO] +- javax.xml.bind:jaxb-api:jar:2.2.11:compile
  [INFO] +- com.sun.xml.bind:jaxb-impl:jar:2.2.11:runtime
  [INFO] +- com.sun.xml.bind:jaxb-core:jar:2.2.11:runtime
  [INFO] +- org.eclipse.persistence:eclipselink:jar:2.6.1:runtime
  [INFO] |  +- org.eclipse.persistence:javax.persistence:jar:2.1.0:runtime
  [INFO] |  +- org.eclipse.persistence:commonj.sdo:jar:2.1.1:runtime
  [INFO] |  +- javax.validation:validation-api:jar:1.1.0.Final:runtime
  [INFO] |  \- org.glassfish:javax.json:jar:1.0.4:runtime
  [INFO] +- com.sun.xml.bind:jaxb-xjc:jar:2.2.11:runtime
  [INFO] \- javax.xml.stream:stax-api:jar:1.0-2:runtime
  </code></pre>
  
  <p><strong>Edit:</strong>
  This is my web.xml part:</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;api-service-endpoints&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;jersey.config.server.provider.packages&lt;/param-name&gt;
          &lt;param-value&gt;
                       com.mypack
          &lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  </code></pre>
  
  <p>However, I am getting <code>null</code> values, not alphabetic, and with dates represented in milliseconds.</p>
  
  <p><strong>Update:</strong>
  After updating the dependencies, I am getting this exception:</p>
  
  <pre><code>        &lt;pre&gt;org.glassfish.jersey.server.ContainerException: java.lang.NoSuchMethodError: com.fasterxml.jackson.jaxrs.cfg.EndpointConfigBase.&amp;lt;init&amp;gt;(Lcom/fasterxml/jackson/databind/cfg/MapperConfig;)V
      org.glassfish.jersey.servlet.internal.ResponseWriter.rethrow(ResponseWriter.java:278)
      org.glassfish.jersey.servlet.internal.ResponseWriter.failure(ResponseWriter.java:260)
      org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:509)
      org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:334)
      org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
      org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
      org.glassfish.jersey.internal.Errors.process(Errors.java:315)
      org.glassfish.jersey.internal.Errors.process(Errors.java:297)
      org.glassfish.jersey.internal.Errors.process(Errors.java:267)
      org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
      org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
      org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
      org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471)
      org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425)
      org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383)
      org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336)
      org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      com.anaplan.api.security.auth.AuthenticationFilter.doFilter(AuthenticationFilter.java:63)
  &lt;/pre&gt;
  </code></pre>
  
  <p><strong>Update1:</strong>
  I was reading about depedencies issues that jersey have and when I removed:</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.21&lt;/version&gt;
    &lt;scope&gt;runtime&lt;/scope&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>I am getting  the result as expected, BUT, only in xml, not in json.
  any ideas?</p>