Jersey – Rest – POJO mapping error

I have recently created a Jersey Rest application with Jetty and faced an issue while POJO mapping.

The exception trace is given below,


[INFO] No Transaction manager found - if your webapp requires one, please configure one.
[INFO] Initiating Jersey application, version Jersey: 2.6 2014-02-18 21:52:53...
[WARNING] unavailable
MultiException stack 1 of 3
java.lang.NullPointerException
	at com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.setConfiguration(AbstractJAXBProvider.java:113)
	at com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider.setConfiguration(JSONRootElementProvider.java:86)

After carefully analyzing by running mvn dependency:tree, I have come to know that in my pom.xml, I included the below dependency which has caused this issue

    <dependency>
          <groupId>com.sun.jersey</groupId>
          <artifactId>jersey-json</artifactId>
          <version>1.19</version>
      </dependency>
      <dependency>
          <groupId>com.sun.jersey</groupId>
          <artifactId>jersey-server</artifactId>
          <version>1.19</version>
      </dependency>

The issue is because of the jersey-core.jar. By removing the above dependencies fixed the issue. Make sure to include all the relevant jackson jars for POJO Mapping

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s