I'm having some trouble with NPE's while trying to use POJOS as Parameters. I'm deploying the war maven generates to a tomcat 7 with default configurations.
The signature of my method looks like this.
@POST
@Produces({MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_JSON})
@Path("/do/")
public OtherPojo doSomething(MyPOJO pojo) {
The Pojo is annotated with @XmlRootElement However when I invoke the url, the pojo is null and thus I get th NPE. My pom.xml
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-metainf-services</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
I've tried with jersey 2.13 and 2.6 And jackson 2.4
Additionally I didnt set up an Application, my classes just have the annotation
@Path("/somePath/")
public class SomeClass {
And this is configured in my web.xml
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.beer.routes</param-value>
</init-param>
I read I might need to Register the JacksonFeature, but I couldn't figure out how to do that.