1

While learning JSF and trying to open xhtml pages in browser I'm constantly having "error parsing XML: element not found" problem. I searched the web and stackoverflow in order to fix it, but none of the solutions worked for me.

I am quite new to JSF and probably doing some sort of newbie mistake. The problem occurs with all pages in my app so I think that my web.xml might be not correct?

Application server is JBoss and the browser is Firefox, on Ubuntu 14.04.

Here is the web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>HomeLib</display-name>
  <welcome-file-list>
    <welcome-file>index.xhtml</welcome-file>
  </welcome-file-list>
  <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>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
  </context-param>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
</web-app>

And my pages have the following structure:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"   
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  

    <h:html xmlns="http://www.w3.org/1999/xhtml"  
        xmlns:ui="http://java.sun.com/jsf/facelets"  
        xmlns:h="http://java.sun.com/jsf/html"  
        xmlns:f="http://java.sun.com/jsf/core">  

    <!-- here goes the content -->

    </h:html>  
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555

1 Answers1

0

i quess the way you call it is wrong.

your URL in the browser should be:

host-name:port/project-name/faces-pattern

in your case:

http://localhost:8080/HomeLib/faces/

this equivalent to:

http://localhost:8080/HomeLib/faces/index.xhtml

faces url pattern (in your case /faces/*) is necessary to tell the server that the requested URL should be handled via the FacesServlet

Rami.Q
  • 2,486
  • 2
  • 19
  • 30