0

I was going through one of the books on JSF (JavaSever Faces - Introduction by Example) and I found the following excerpt

Prior to JSF 2.0, in order to enable the JSF servlet to translate the XHTML page, you needed to ensure that the web.xml file contained a servlet element indicating the javax.faces.webapp.FacesServlet class and its associated servlet-mapping URL. Since the release of JSF 2.0, if using a Servlet 3.x container, the FacesServlet is automatically mapped for you, so there is no requirement to adjust the web.xml configuration.

I decided to try it out, but did NOT work and getting 404 error.

web.xml

    <!-- Commenting this out in Glassfish server based on the book's guidelines -->
    <!-- 
    <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>

Prior to moving to Glassfish 4.x I already had this working on Tomcat 8. The weird part is as soon as I uncomment the FacesServlet mapping in deployment desriptor everything works great and I do not get 404.

Is Glassfish 4.x a Servlet 3.x container? Am I doing something wrong or are the book guidelines incorrect?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Nital
  • 5,784
  • 26
  • 103
  • 195
  • Well, I could certainly do that, but the book that I am using is just an year old publication http://www.amazon.com/JavaServer-Faces-Introduction-Josh-Juneau/dp/1484208390/ref=sr_1_4?ie=UTF8&qid=1440104511&sr=8-4&keywords=javaserver+faces – Nital Aug 20 '15 at 21:09
  • It will only work when your webapp runs in Servlet 3.0+ modus. Your problem suggests thar your web.xml is declared conform e.g. Servlet 2.5 or lower. The `` and all included DTD and XSD are relevent to determine this, but this detail is missing in your question. – BalusC Aug 21 '15 at 06:22
  • @BalusC - I just checked and found that my webapp version is 3.1 – Nital Aug 21 '15 at 20:42

0 Answers0