title: Jersey not able to map json request to class
body: <p>I m able to run Jersey with Json output and able to get "GET" requests with JSon mapping without any problems.</p>
  
  <p>I was also having some JSON methods which were "POST" methods and they are mapping to Java classes like in this method -</p>
  
  <pre><code>@POST
  @Consumes({MediaType.APPLICATION_JSON})
  @Produces({MediaType.TEXT_PLAIN})
  @Path("/post")
  public String postPerson(Person pers) 
  </code></pre>
  
  <p>For your reference I m following the guide <a href="https://www.nabisoft.com/tutorials/java-ee/producing-and-consuming-json-or-xml-in-java-rest-services-with-jersey-and-jackson" rel="nofollow noreferrer">here</a> or <a href="https://www.mkyong.com/webservices/jax-rs/json-example-with-jersey-jackson/" rel="nofollow noreferrer">here</a></p>
  
  <p>On giving a valid post request on these, they all started to throw the below error -</p>
  
  <p>My maven dependencies, pom.xml is file at the end of the question - </p>
  
  <pre><code>exception
  
  javax.servlet.ServletException: java.lang.NullPointerException
  org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:489)
  org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
  org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
  org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
  org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
  
  root cause
  
  java.lang.NullPointerException
  newa.PersonResource.postPerson(PersonResource.java:31)
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  java.lang.reflect.Method.invoke(Method.java:498)
  org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
  org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
  org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
  org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:205)
  org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
  org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
  org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
  org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
  org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
  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:473)
  org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
  org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
  org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
  org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
  </code></pre>
  
  <p>The Person class -</p>
  
  <pre><code>  @JsonInclude(Include.NON_EMPTY)
  public class Person {    
  private String firstName;
  private String lastName;
  public void setLastName(String lastName) {
      this.lastName = lastName;
  }
  public String getLastName() {
      return lastName;
  }
  public String getFirstName() {
      return firstName;
  }
  public void setFirstName(String firstName) {
      this.firstName = firstName;
  }
  }
  </code></pre>
  
  <p>The data I m sending using postman(Chrome extension) is in like -</p>
  
  <p><a href="https://i.stack.imgur.com/pMK2e.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pMK2e.jpg" alt="screenshot"></a></p>
  
  <p>My pom.xml file -</p>
  
  <pre><code> &lt;dependencies&gt;
  
  
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
          &lt;version&gt;3.1.0&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
  
  
      &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.24&lt;/version&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.24&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-media-json-processing&lt;/artifactId&gt;
          &lt;version&gt;2.24&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-media-multipart&lt;/artifactId&gt;
          &lt;version&gt;2.24&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-media-sse&lt;/artifactId&gt;
          &lt;version&gt;2.24&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-core&lt;/artifactId&gt;
          &lt;version&gt;1.8&lt;/version&gt;
          &lt;type&gt;jar&lt;/type&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  </code></pre>