Creating a CDI web application with Apache Karaf
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.
Getting ready
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 ...
Get Apache Karaf Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.