Search code examples
javaprimefacesjsf-2.2eclipse-kepler

Required files and configuration to create a jsf2.2 web application


I am a total beginner i am using eclipse kepler to create my web application: an eduction portal i did already set the glassfish4 server(its working) and the properties of the project i am using primefaces along with jsf 2.2 i created the first page and i wanted to to try to run it on the server but nothing is showed its a 404 error The requested resource is not available. and i already added the primefaces jar to the classpath this is the code of the page index.html

    <!DOCTYPE html>
    <html
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui"
    >
    <head>
    </head>
    <f:view contentType="text/html">
    <h:head />
    <h:body>
    <h:form>
    <p:spinner />
    </h:form>
    </h:body>
    </f:view>
    </html>

and this is the code in my web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee     http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" 
    id="WebApp_ID" version="3.1"
    xmlns:p="http://primefaces.org/ui">
    <display-name>Portail</display-name>
    <welcome-file-list>
    <welcome-file>index.html</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>*.html</url-pattern>
    </servlet-mapping>
    </web-app>

i followed some steps from this article to create it http://computingat40s.wordpress.com/creating-a-simple-jsf-web-application-from-the-ground/ and my lib directory still empty i didn't add anything to it i didn't even started creating the entities


Solution

  • From the comments:

    html does not allow faces servlet parsing. Please change your files to xhtml: these files are made by opening standard xml (where you also put the xmlns declarations)

    This snippet is directly taken from the web-application i currently work on.

    <?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">
    <h:html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:p="http://primefaces.org/ui"
        xmlns:o="http://omnifaces.org/ui"
        xmlns:of="http://omnifaces.org/functions">
    <h:head />
    

    please remember changing your Faces Servlet filter in the web-config