Intro

Java-EE5 application servers don't provide a CDI implementation out-of-the-box. So it's possible to use an implementation of your choice. However, the problem is that there is no given order for the bootstrapping process. Therefore, it's required to ensure that the CDI container gets bootstrapped before the JSF container. The Java-EE5 support modules ensure that and this page shows how to use them.

Hint

This modules are available since v1.0.3

Configuration

Java-EE5 Application Servers with Apache OpenWebBeans

Add Apache OpenWebBeans to the project (see the documentation of the project).

Java-EE5 module for OpenWebBeans
<dependency>
    <groupId>org.apache.myfaces.extensions.cdi.modules.jee5-support</groupId>
    <artifactId>myfaces-extcdi-jee5-openwebbeans-support</artifactId>
    <version>${myfaces.codi.version}</version>
    <scope>runtime</scope>
</dependency>

Furthermore, you have to replace the WebBeans listener in the web.xml with the listener provided by MyFaces CODI.

Replacement for the web.xml
<listener>
    <listener-class>org.apache.myfaces.extensions.cdi.openwebbeans.startup.WebBeansAwareConfigurationListener</listener-class>
</listener>

Java-EE5 Application Servers with Weld

Add Weld to the project (see the documentation of the project).

Java-EE5 module for Weld
<dependency>
    <groupId>org.apache.myfaces.extensions.cdi.modules.jee5-support</groupId>
    <artifactId>myfaces-extcdi-jee5-weld-support</artifactId>
    <version>${myfaces.codi.version}</version>
    <scope>runtime</scope>
</dependency>

Furthermore, you have to replace the Weld listener in the web.xml with the listener provided by MyFaces CODI.

Replacement for the web.xml
<listener>
    <listener-class>org.apache.myfaces.extensions.cdi.weld.startup.WeldAwareConfigurationListener</listener-class>
</listener>
  • No labels