Title: OpenWebBeans FAQ
OpenWebBeans in a great match for web-apps and should work well for your favorite Servlet Containers such as Jetty or Tomcat. To add OpenWebBeans to your Servlet Container project you need to take the following steps.
You can add OpenWebBeans to your project manually by adding jars or with Apache Maven. How to download is explained here: download page. The binary distributions include all the jars you need and the download page lists all the maven dependencies. But since OpenWebBeans is modular you should read below so you know what to add.
Several API bundles exists for java EE and they are mostly compatible with OpenWebBeans. If you already include one of these you might not need any api jars. CDI and thus OpenWebBeans depends on the following four apis:
You will only reference these API:s in your own project. This way your project will stay CDI vendor neutral. A typical use case would be to add all four of the above to your parent-pom or your core module.
For Servlet Container projects such as Tomcat and Jetty you always start with:
The following plugins are very useful if you need JSF, expression language (el) etc. Add accordingly to your needs.
If the project uses Expression Language add EL plugin accordingly to your version. This is required for using EL.
If the project uses Tomcat 7 or above you can add the respective plugin. This is not required but enables injection in Servlets and Filters. Note that the tomcat7 plugin works perfectly fine with Tomcat 8, 8.5 and even Tomcat 9.
Simply put the following listener in web.xml:
<listener> <listener-class>org.apache.webbeans.servlet.WebBeansConfigurationListener</listener-class> </listener>
This is not required if you use Tomcat and added the corresponding Tomcat plugin because in that case it's managed by the plugin.
From here you might want to look at our samples selection: samples.