Search code examples
javagoogle-app-enginejsf-2

Google App Engine Jsf2 welcome-file-list does not working


I have a web app. I am using JSF2 framework. My problem started when running this project on google app engine server.

<welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>

this part of web.xml file does not give correct output. When I entered localhost:8080, index.html page not found. What is wrong? Please help. Full web.xml file is:

 <?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_2_5.xsd"
         id="WebApp_ID" version="2.5">
    <display-name>
        Wildstar Technologies, LLC. Google AppEngine JSF 2.0 Template
    </display-name>
    <description>
        Template JSF 2.0 application configured to run on the Google
        AppEngine for Java.
    </description>

    <context-param>
        <param-name>primefaces.THEME</param-name>
        <param-value>cupertino</param-value>
    </context-param>
    <context-param>
        <param-name>com.ocpsoft.pretty.DEVELOPMENT</param-name>
        <param-value>/WEB-INF/pretty-config.xml</param-value>
    </context-param>
    <servlet>
        <display-name>Remote API Servlet</display-name>
        <servlet-name>RemoteApiServlet</servlet-name>
        <servlet-class>com.google.apphosting.utils.remoteapi.RemoteApiServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>RemoteApiServlet</servlet-name>
        <url-pattern>/remote_api</url-pattern>
    </servlet-mapping>
    <servlet>
        <servlet-name>ShowImage</servlet-name>
        <servlet-class>mucayufa.web.jsf2.ferizliAdmin.beans.ShowImage</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>ShowImage</servlet-name>
        <url-pattern>/show</url-pattern>
    </servlet-mapping>
    <servlet>
        <servlet-name>Upload</servlet-name>
        <servlet-class>mucayufa.web.jsf2.ferizliAdmin.beans.UploadDocument</servlet-class>
    </servlet>

    <servlet>
        <servlet-name>Serve</servlet-name>
        <servlet-class>mucayufa.web.jsf2.ferizliAdmin.beans.Serve</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>Upload</servlet-name>
        <url-pattern>/upload</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>Serve</servlet-name>
        <url-pattern>/serve</url-pattern>
    </servlet-mapping>
    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern><!--*/-->
    </filter-mapping>
    <filter>
        <filter-name>PrimeFaces FileUpload Filter</filter-name>
        <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>PrimeFaces FileUpload Filter</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>

    <!-- Processes application requests -->
    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/applicationContext.xml</param-value>
        </init-param>

    </servlet>

    <servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>/*</url-pattern><!--*/-->
    </servlet-mapping>

    <filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern><!--*/-->
    </filter-mapping>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!-- ***** Designate server-side state saving. *****  -->
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
    </context-param>

    <context-param>
        <param-name>com.sun.faces.expressionFactory</param-name>
        <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
    </context-param>
    <!-- Disable use of threading for single-threaded environments such as
 the Google AppEngine. -->
    <context-param>
        <param-name>com.sun.faces.enableThreading</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Production</param-value>
    </context-param>
    <!-- ***** Load the JavaServer Faces Servlet ***** -->
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <!-- ***** Load the JavaServer Faces Servlet ***** -->

    <!-- Map these files with JSF -->
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern><!--*/-->
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.faces</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
    <!-- ***** Specify session timeout of thirty (30) minutes. ***** -->
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>
 <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
</web-app>

Solution

  • Not sure if this is your problem, but my experience is that sometimes under devmode, static resources are not found.

    While it's stated here "By default, all files in the WAR are treated as both static files and resource files" https://developers.google.com/appengine/docs/java/config/appconfig#Static_Files_and_Resource_Files, I have definitely experienced cases where static resources do not resolve under dev mode even though they should and do in production.

    What I mean to say is that without a mapping of < include path="**.html" /> in appengine-web.xml, for example html files are not treated as static resources.

    I'd try an explicit < include> mapping in appengine-web.xml and make sure that no < exclude> wildcard paths could possibly resolve to the file because the dev server doesn't handle that well it seems.