Using Jersey 2.1 with CDI

cdi, glassfish, guava, jakarta-ee, jersey

Solution

CDI has some questionable behavior. We think we have two workarounds: one that you can do yourself and one that will work automatically when we release Guava 15.0. You can read more about the problem here.

Problem

I try to use `Jersey 2.1` and `CDI` in my `Java EE 7` project which is deployed on `Glassfish 4.0.` Jersey modules depend on Guava libraries. But using Guava libraries (14.0.1) with CDI results the following exception being thrown. ``` CDI deployment failure:WELD-001408 Unsatisfied dependencies for type [Set<Service>] with qualifiers [@Default] at injection point [[BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject com.google.common.util.concurrent.ServiceManager(Set<Service>)]. ``` How can I overcome this issue?

Original source