Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't deploy *.war to Glassfish 4

I have an Bean interface, AbstractBean (implements Bean) and SpecificBean (extends AbstractBean). I want to inject SpecificBean by following code snippet:

@Stateless
@Specific
public class SpecificBean extends AbstractBean {..}

@Path("resource")
public class Service {
    @Inject
    @Specific
    private Bean bean;
}

When I trying to deploy this to glassfish, I see next error:

An error has occurred Error occurred during deployment: Exception while loading the app : CDI deployment failure:WELD-001408 Unsatisfied dependencies for type [IterableProvider>] with qualifiers [@Default] at injection point [[BackedAnnotatedParameter] Parameter 2 of [BackedAnnotatedConstructor] @Inject org.glassfish.jersey.internal.inject.JerseyClassAnalyzer(@Named ClassAnalyzer, IterableProvider>)].

If delete all annotations (expected @Path) application deploys without any errors.

like image 696
user2966560 Avatar asked Nov 08 '13 21:11

user2966560


2 Answers

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

like image 152
user2966560 Avatar answered Sep 19 '22 17:09

user2966560


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>
like image 39
Marcio Jasinski Avatar answered Sep 20 '22 17:09

Marcio Jasinski