eclipse-ee4j / eclipse-ee4j/jersey
Spring6-jersey CDI / integration failing due to HK2 injection
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
Spring4-jersey integration was working fine until a java 17 migration was attempted.
As part of the migration, dependencies modified to spring6 (6.0.4)-jersey(3.1.1).
However the request scope is failing with the below exception.
`Getting the exception org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available in __HK2_Generated_0 for injection at SystemInjecteeImpl(requireType=XYZ, parent=ABC, qualifiers={},position=0,optional=false,self=false,unqualified=null,5088)...`
Question around the class, in version 3.1.1,
`public class SpringComponentProvider implements ComponentProvider `
initialize() is just checking jdk version where as the older version (eg:2.36) was trying to bridge with HK2 injection and was able to inject the beans created in the spring container.
+ bind() is returning false.
Especially why is jersey-cdi relying on hk2 and not looking for spring cdi offered ?
```
at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:702)
at org.glassfish.jersey.inject.hk2.AbstractHk2InjectionManager.getInstance(AbstractHk2InjectionManager.java:160)
at org.glassfish.jersey.inject.hk2.ImmediateHk2InjectionManager.getInstance(ImmediateHk2InjectionManager.java:30)
at org.glassfish.jersey.internal.inject.Injections.getOrCreate(Injections.java:105)
at org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.getInstance(MethodHandler.java:260)
at org.glassfish.jersey.server.internal.routing.PushMethodHandlerRouter.apply(PushMethodHandlerRouter.java:51)
```
The dependencies in place :
- org.springframework:spring-web -> 6.04
- org.springframework:spring-context -> 6.04
- org.glassfish.jersey.ext:jersey-spring6 -> 3.1.1
- org.glassfish.jersey.containers:jersey-container-servlet -> 3.1.1
- org.glassfish.jersey.containers.glassfish:jersey-gf-cdi ->3.1.1
- org.glassfish.jersey.ext.cdi:jersey-cdi1x -> 3.1.1
- jakarta.servlet:jakarta.servlet-api -> 2.0.1
- jakarta.ws.rs:jakarta.ws.rs-api -> 3.1.0
Any explicit configurations to be made for this to work ?
Any inputs or help much appreciated.
Contributor guide
Assessment
This issue has not been assessed yet.