Using Jersey 2.1 with CDI

I am trying to use Jersey 2.1 and CDI in my Java EE 7 project, which deploys on Glassfish 4.0.

Jersey modules are dependent on Guava libraries . But when using the Guava libraries (14.0.1) with CDI, the following exception occurs.

 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 solve this problem?

+6
source share
2 answers
+3
source

The problem is that Guava classes are annotated, and CDI is trying to inject dependencies into them.

The glassfish / modules directory contains guava.jar. so just installing the guava dependency on the provided (or test) in maven solves the problem.

+2
source

Source: https://habr.com/ru/post/951552/


All Articles