Code Bug Fix: CDI Bean method not called when using myfaces bundled in webapp and run on Wildfly

Original Source Link

I want to migrate my JSF Application from ManagedBean to CDI Beans.

First of all I have done a simple test to see if CDI are working, but they don’t.
Here my example, using Wildfly 10 and myfaces 2.2

beans.xml in .WEB-INF

<beans xmlns=""

xhtml page:

<!DOCTYPE html>

<html xmlns=""


    <h:outputText value="#{CDITest.hello}"/>
    <h:outputText value="test"/>


The backing Bean

import javax.enterprise.context.SessionScoped;
import javax.inject.Named;

  public class CDITest implements Serializable{

    public String getHello(){
      return "Hello";

The output


No error message (!) and no call to CDITest.getHello() method. What I’m missing?

The problem is more general.
In JSF 2.3, JSF picks up CDI via BeanManager#getELResolver. In pre JSF 2.3, the container or the CDI impl has to marry JSF and CDI.

I think you need to Declare a @FacesConfig annotated class to activate CDI in JSF 2.3

import javax.enterprise.context.ApplicationScoped;
import javax.faces.annotation.FacesConfig;

public class ConfigurationBean {


Upgrading to myfaces-2.3.6 (jsf 2.3) on Wildfly 19.0.0 solved the issue. Note that you need a @FacesConfig class as suggested by @Cristyan.

Note also that using Mojarra the issue didn’t happen and the Bean worked as expected (for both Widlfly 10 and Widlfly 19).

Tagged : / / /

Leave a Reply

Your email address will not be published. Required fields are marked *