I set up an eclipse WebApp project and placed Jersey and Jackson JARs in the WEB-INF/lib directory. I want to use JSON serialization but didn\'t manage to fix this error:>
All you need is to register JacksonJsonProvider
. There are many ways to achieve that:
jersey.config.server.provider.classnames
com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider
or
javax.ws.rs.core.Application
in the web.xml
javax.ws.rs.Application
com.rest.MyApplication
and then do all the configuration in the application class:
package com.rest;
import org.glassfish.jersey.server.ResourceConfig;
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
public class MyApplication extends ResourceConfig {
public MyApplication() {
packages("com.rest");
register(JacksonJsonProvider.class);
}
ResourceConfig
is a subclass of javax.ws.rs.Application
and gives you some helper methods that makes the registration easy.
or
jersey-media-json-jackson
org.glassfish.jersey.media
jersey-media-json-jackson
2.13
But be careful. It will register more than you need:
Take a look at the source code to see what it does.