I'm started to learn JSF
. I'm learning from a videotutorial that uses Eclipse
but I'd like to use IntelliJ
. I managed to do almost everything but I have encounter one problem. Simple HTML pages are shown correctly in my webrowser but JSF pages (i.e. .xhtml
) are not, ie. my webbrowser shows a blank page, but this is exacly the same page that I have in Intellij (all tags etc. are there). I guess this is because JSF pages are sent to the browser as is (i.e. raw), and tags thats start with h:
(e.g. <h:head>
) and it fails to recognize those tags correctly. I'm using Tomcat 8.5.20
(latest) as server. Here's my simple JSF page:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>First JSF app</title>
</h:head>
<h:body>
<h3>Enter your name:</h3>
<h:form>
<h:inputText value="#{helloBean.name}"></h:inputText>
<h:commandButton value="Submit" action="hello"></h:commandButton>
</h:form>
</h:body>
</html>
As requested, my faces-config.xml
:
<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
</faces-config>
My web.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<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>
</web-app>
As per request
JSF libraries seem to be available to Tomcat.
Thanks to @asgs I've found an error in Tomcat log. It reads as follows:
java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet
However, I have javax.faces-2.2.1.jar
in lib folder.