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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With