I'm trying to run a simple JSF exemple using JSF 2.2 libraries with Tomcat 8.0.3.0. Libraries and Tomcat are provided out of the box with netbeans 8.
Here is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 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">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
The managed bean to display a message
@Named(value = "helloWorldController")
@RequestScoped
public class HelloWorldController {
private String hello;
/**
* Creates a new instance of HelloWorldController
*/
public HelloWorldController() {
hello = "Hello World!";
}
public String getHello() {
return hello;
}
public void setHello(String hello) {
this.hello = hello;
}
}
And index.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Facelet Title</title>
</h:head>
<h:body>
<p>
#{helloWorldController.hello}
</p>
</h:body>
</html>
I tried with different url:
http://localhost:8084/JSFTest/faces/index.xhtml => does not render anything
http://localhost:8084/JSFTest/index.xhtml => renders #{helloWorldController.hello} litteraly
I added Java EE 6 Aeb Api library provided by Netbeans in the path so it is deployed. I also tried with Java EE 7 Web Api Library.