jersey icon indicating copy to clipboard operation
jersey copied to clipboard

Ambiguous dependencies injection when using the new CDI2

Open hypnoce opened this issue 8 years ago • 5 comments

Hi Jersey team,

using the new CDI2 bridge for jersey, I have this error :

org.jboss.weld.exceptions.DeploymentException: WELD-001409: Ambiguous dependencies for type HttpServletRequest with qualifiers @Default
  at injection point [BackedAnnotatedField] @Inject org.glassfish.jersey.tests.integration.jersey2704.TestResource.request
  at org.glassfish.jersey.tests.integration.jersey2704.TestResource.request(TestResource.java:0)
  Possible dependencies: 
  - org.glassfish.jersey.inject.cdi.se.bean.SupplierBeanBridge@56820446,
  - org.glassfish.jersey.inject.cdi.se.bean.SupplierBeanBridge@c14bbab

	at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:383)
	at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:287)
	at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:140)
	at org.jboss.weld.bootstrap.Validator.validateCustomBean(Validator.java:195)
	at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:520)
	at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:63)
	at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:61)
	at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:62)
	at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:55)
	at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

Here a test case for it : https://github.com/hypnoce/jersey/commit/7e8a4c7b88c3e57946541335877b545791422905

The execution flow is the following :

hypnoce avatar Jul 18 '17 13:07 hypnoce

I have the same problem. Is there any workaround that I can do on the application side before the bug is fixed ? thanks

cthiebaud avatar Aug 01 '17 17:08 cthiebaud

Same problem here. Any workarounds for that? I need to access the HttpServletRequest or the Session inside of a ContainerRequestFilter.

dan-osterrath avatar Mar 20 '18 09:03 dan-osterrath

Even programmatic lookup via CDI.current().select() was not successfully. I could iterate over the 2 found Instances for HttpServletRequest, unfortunately both were implementations of ResponseFacade. WTF?!?

My workaround was a migration to RestEasy. #SAD

dan-osterrath avatar Mar 23 '18 16:03 dan-osterrath

In general, I believe jersey is a dying project. No bug fix, no impovements, poor commiter community. Resteasy (wildfly-swarm flavor) is the way to go for microservices with java standards.

hypnoce avatar Mar 28 '18 17:03 hypnoce

@hypnoce I think the community is waiting on Oracle for the Jersey to be handed over to the Eclipse Foundation, at that point I expect work on it to resume in earnest. See also #3710.

Cousjava avatar Mar 29 '18 08:03 Cousjava