You need to have a JSF 2.0 compliant /WEB-INF/faces-config.xml
file in order to get JSF to interpret the annotations.
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
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/web-facesconfig_2_0.xsd"
version="2.0">
<!-- Config here. Can even be kept empty. -->
</faces-config>
If you already have one or if that doesn't solve the problem, please pay attention to server startup logs if you don't see any warnings/errors.
By the way, your /WEB-INF/web.xml
file is declared conform Servlet 2.5 specification. While this may not necessarily harm, it makes no sense if you're using a Servlet 3.0 compliant container. Update the root declaration as follows:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
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/web-app_3_0.xsd"
version="3.0">
<!-- Config here. -->
</web-app>
The /WEB-INF/beans.xml
is intented for CDI annotations like @Named
, @Inject
and so on. Just a completely empty file is sufficient to turn it on. It has totally no relationship to JSF annotations like @ManagedBean
, @ManagedProperty
and so on. It should also not be confused/mixed with each other.