How to integrate JAX-RS with CDI in a Servlet 3.0 container

后端 未结 3 2078
失恋的感觉
失恋的感觉 2020-12-16 18:32

I have a web application running on a Servlet 3.0 container (Jetty 9.0.4) using JSF 2.2 (Mojorra 2.1.3) & CDI 1.1 (Weld 2.0.3). No full-fledged application server is use

3条回答
  •  粉色の甜心
    2020-12-16 19:19

    I solved my problem.

    The problem is, that Jersey JAX-RS implementation uses the HK2 dependency injection framework and this framework is simply not aware of the CDI beans. And by following the idea of the accepted answer in this post, I make the CDI beans available for the HK2 injection bindings and the injection of my application scoped beans works fine now.

    But I really wonder why it is so cumbersome to bring together two constituent parts of Java EE.

    Update: As G. Demecki mentioned in a comment, this is solution is no longer needed! But it helped me out at the time of asking this question.

提交回复
热议问题