Nowadays, modern web applications use Contexts and Dependency Injection (CDI) to wire the application. In the context of OSGi, it would be nice to have this working together with OSGi services. Pax Web, together with Pax CDI, takes care of this scenario.
Besides the installation of the WAR feature, it is required to install Pax CDI. Use the following commands to install them:
feature:install war feature:install pax-cdi-web-openwebbeans
Alternatively, you can use the weld
command as follows:
feature:install pax-cdi-web-weld
The source code for this recipe can be found at https://github.com/jgoodyear/ApacheKarafCookbook/tree/master/chapter4/chapter4-recipe10.
This recipe needs the bundle and web submodules. The bundle submodule contains the OSGi service, and the web submodule contains the CDI web application.