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?
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.
The problem here is that Guava classes are annotated, and CDI tries to inject dependencies into them.
The glassfish/modules directory contains a guava.jar. so simply setting the guava dependency to provided (or test) in maven solves the problem.
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