Force Glassfish4 to use Jackson instead of Moxy

You need to register JacksonFeature in your application if you want to use Jackson as your JSON provider (by registering this feature your disable MOXy to be your JSON provider).

You can do it either in Application subclass:

public class MyApplication extends Application {

    public Set<Class<?>> getClasses() {
        final Set<Class<?>> classes = new HashSet<Class<?>>();

        // Add root resources.
        classes.add(HelloWorldResource.class);

        // Add JacksonFeature.
        classes.add(JacksonFeature.class);

        return classes;
    }
}

or in ResourceConfig:

final Application application = new ResourceConfig()
        .packages("org.glassfish.jersey.examples.jackson")
        .register(MyObjectMapperProvider.class)  // No need to register this provider if no special configuration is required.
        // Register JacksonFeature.
        .register(JacksonFeature.class);

See Jackson section in Jersey Users Guide for more information.


Answer by Michal Gajdos is correct, just to add to that, add this dependency in your pom.xml ,

<dependency>
    <groupId>org.glassfish.jersey.media</groupId>
    <artifactId>jersey-media-json-jackson</artifactId>
    <version>2.26</version>
</dependency>