1

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. enter image description here

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.

menteith
  • 596
  • 14
  • 51
  • Can you post the error message you are getting? – Yohannes Gebremariam Aug 20 '17 at 15:27
  • I don't get any error beside the fact that the webrowser shows an empty page. – menteith Aug 20 '17 at 15:49
  • Can you post your web.xml and your project file system structure? Your jsf is being served without getting rendered to html because of a mis-configuration in your app, not intellij, I suspect. – Mustafa Aug 20 '17 at 15:53
  • Sure, I will do it right now. – menteith Aug 20 '17 at 15:58
  • don't you need to make the JSF lib available to your Tomcat container (assuming it's not already bundled)? Also, when you view source from the browser, what do you see? Are there any errors logged in the Browser console? – asgs Aug 20 '17 at 18:56

0 Answers0