I created this simple CDI bean:
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.inject.Named;
@Named("DashboardController")
@ViewScoped
public class Dashboard implements Serializable
{
.......
}
I removed all configuration from faces-config.xml. I created this beans.xml file into WEB-INF directory:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
When I opened the JSF page the bean cannot be found. Can you tell me what am I missing? I don't want to declare the beans into faces-config.xml.
P.S I don't know if this is important or not but this is a WAB package with CDI beans.
javax.faces.bean.ViewScoped
from JSF doesn't mix withjavax.inject.Named
from CDI. You should use plain CDI or JSF managed bean, not both. – Luiggi Mendoza