Open tandraschko opened 3 years ago
NOTE: adding the cdi-se module to a running tomcat+owb combination results in a exception, as jersey would like to start a new CDI application for the WebApp ClassLoader, but CDI is already attached to this ClassLoader
Jersey already has an integration module for CDI, org.glassfish.jersey.ext.cdi:jersey-cdi1x
, which you would likely need in conjunction with other cdi modules, such as org.glassfish.jersey.ext.cdi:jersey-cdi1x-servlet
(to prevent complaining about multiple injection managers).
That integration module still requires HK2, though. The current plan for having CDI as the only DI framework (without HK2) is for Jersey 4.
We released a very beta module for CDI injection manager. The issue is that CDI requires to know all the bindings before Jersey starts. For that, we introduced a BootStrapPreinitialization SPI that can be utilized. We are able to run some tests in the Jersey test module with the CdiInjectWeld
profile.
In the future, we may move the SPI to jersey-common
. The whole injection module may look quite different in the future, depending on the CDI lite requirements and capabilities.
Sometimes people already have a working Tomcat + CDI (doesnt matter if Weld or OWB) setup. In this case it should be possible to easily add a jersey-cdi module, which relies on the already running CDI container.
A good alternative would be to rename the "cdi-se" module to "cdi" and check there for a running CDI container, first.