Can't deploy *.war to Glassfish 4

Removed jersey from the dependencies list in maven pom.xml (jersey already contains in glassfish 4) and it deploys ok now.


I found this questions with similar problem and just want to add my "2 cents". In my case, I was using Jersey 2.0 with Jackson in order to transform JSON to objects and object to JSON from my rest interfaces. This means that I had to register JacksonFeature on ResourceConfig like this:

import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.message.GZipEncoder;
import org.glassfish.jersey.server.ResourceConfig;

public class JacksonRestConfiguration extends ResourceConfig {

public JacksonRestConfiguration() {
    register( new GZipEncoder() );
    register( JacksonFeature.class );
}

I also disabled Moxy on my Application extension:

import org.glassfish.jersey.CommonProperties;

@ApplicationPath("services")
public class RestApplication extends Application implements Feature {

    public boolean configure( final FeatureContext context ) {
        String postfix = '.' + context.getConfiguration().getRuntimeType().name().toLowerCase();
        context.property( CommonProperties.MOXY_JSON_FEATURE_DISABLE + postfix, true );    
        return true;
    }
}

Both classes above required me to keep jersey as provided in my pom.xml in order to generate the war file correctly:

    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-json-jackson</artifactId>
        <version>2.13</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-server</artifactId>
        <version>2.13</version>
        <scope>provided</scope>
    </dependency>