9 Replies Latest reply on May 28, 2013 4:44 AM by rhanus

    welcome-file-list in web.xml is ignored ?

    rhanus

      Hi,

       

      I just downloaded wildfly8 and build sample richfaces application but its welcome file is not picked up

       

      Steps:

      • create simple richfaces project by "mvn archetype:generate -DarchetypeGroupId=org.richfaces.archetypes -DarchetypeArtifactId=richfaces-archetype-simpleapp -DarchetypeVersion=4.3.2.Final -DgroupId=org.dummy -DartifactId=rf -Dversion=1.0-SNAPSHOT"
      • build war "mvn package -Pjee6"
      • copy target/rf-jee6.war into standalone\deployments
      • run wildfly's standalone.bat
      • launch browser and try to open http://localhost:8080/rf-jee6 you will get 404
      • if you fix it to http://localhost:8080/rf-jee6/faces/index.xhtml then expected page is available

       

      Regards,

      Radim

        • 1. Re: welcome-file-list in web.xml is ignored ?
          jaikiran

          What exactly does the web.xml contents look like? We had fixed this issue in 8.0.0.Alpha1 and in upstream/master.

          • 2. Re: welcome-file-list in web.xml is ignored ?
            rhanus

            Hi Jaikiran,

             

            web.xml is following:

            <?xml version="1.0" encoding="UTF-8"?>

            <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

             

             

                <display-name>Sample RichFaces 4 Application</display-name>

             

             

                <context-param>

                    <param-name>javax.faces.PROJECT_STAGE</param-name>

                    <param-value>Development</param-value>

                </context-param>

             

             

                <context-param>

                    <param-name>javax.faces.SKIP_COMMENTS</param-name>

                    <param-value>true</param-value>

                </context-param>

             

             

                <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>*.jsf</url-pattern>

                </servlet-mapping>

                <servlet-mapping>

                    <servlet-name>Faces Servlet</servlet-name>

                    <url-pattern>/faces/*</url-pattern>

                </servlet-mapping>

               

                <!-- Resource Servlet - serves static resources and resources for specific components -->

                <servlet>

                    <servlet-name>Resource Servlet</servlet-name>

                    <servlet-class>org.richfaces.webapp.ResourceServlet</servlet-class>

                    <load-on-startup>1</load-on-startup>

                </servlet>

                <servlet-mapping>

                    <servlet-name>Resource Servlet</servlet-name>

                    <url-pattern>/org.richfaces.resources/*</url-pattern>

                </servlet-mapping>

               

                <!-- Resource Mapping - resources will be served compressed and packed in production -->

                <context-param>

                    <param-name>org.richfaces.resourceMapping.enabled</param-name>

                    <param-value>true</param-value>

                </context-param>

             

             

                <session-config>

                    <session-timeout>30</session-timeout>

                </session-config>

             

             

                <welcome-file-list>

                    <welcome-file>faces/index.xhtml</welcome-file>

                </welcome-file-list>

             

             

                <login-config>

                    <auth-method>BASIC</auth-method>

                </login-config>

             

             

            </web-app>

             

            • 3. Re: welcome-file-list in web.xml is ignored ?
              jaikiran

              <servlet-mapping>

                      <servlet-name>Faces Servlet</servlet-name>

                      <url-pattern>/faces/*</url-pattern>

                  </servlet-mapping>

              ...

                <welcome-file-list>

                      <welcome-file>faces/index.xhtml</welcome-file>

                  </welcome-file-list>

              This is a different case than the one we had fixed. I'll check with Stuart if he knows about this one.

              • 4. Re: welcome-file-list in web.xml is ignored ?
                sfcoy

                Radim Hanus wrote:

                ...

                web.xml is following:

                ...

                    <welcome-file-list>

                        <welcome-file>faces/index.xhtml</welcome-file>

                    </welcome-file-list>

                ...

                 

                This is not how welcome files work.

                 

                A welcome file is the name of a resource that should be returned by the server when the requested URL consists of only a directory path.

                 

                For example, if you have the following welcome file:

                {code:xml}<welcome-file>index.xhtml</welcome-file>{code}

                 

                and the user requests the URL "http://yourhost/your-app-context/" (note the trailing "/"), then the container will look for an index.xhtml in the root of your application and use it to generate the response.

                 

                The thing is, the welcome file list applies to all directory paths, so if the user requests "http://yourhost/your-app-context/faces/", then the container will return the result that you were originally expecting. ie. "http://yourhost/your-app-context/faces/index.xhtml".

                If the user requests "http://yourhost/your-app-context/faces/foo/x/y/" then the container will try to return the same result as if the the user had requested "http://yourhost/your-app-context/faces/foo/x/y/index.xhtml".

                 

                See §10.10 "Welcome Files" of the servlet spec for more details.

                • 5. Re: welcome-file-list in web.xml is ignored ?
                  jaikiran

                  I thought the welcome-file would take a mapped path too (like the faces/ in this case). In fact, I vaguely remember having some test application which did something similar (but that was many years back). Perhaps I was misusing that welcome-file list functionality. I'll have to read the servlet spec section you mentioned.

                  • 6. Re: welcome-file-list in web.xml is ignored ?
                    swd847

                    Your case should work, as welcome file should also work against mapped servlets, and the spec does not say anything about not serving welcome files that have an additional slash in them. I will fix this in Undertow upstream.

                    1 of 1 people found this helpful
                    • 7. Re: welcome-file-list in web.xml is ignored ?
                      sfcoy

                      Of course you're correct. I'd attempted to get Radim's use case to work for myself in the distant past (> 10 years?) and concluded that additional slashes were not acceptable.

                      • 8. Re: welcome-file-list in web.xml is ignored ?
                        swd847

                        Its probably not a great idea, as if your page reference any relative resources such as javascript files or images they won't load, but it is still valid according to the spec.

                        • 9. Re: welcome-file-list in web.xml is ignored ?
                          rhanus

                          I forgot to mention that this scenario works well in both jboss-as-7.1 and jboss-eap-6.1

                          I deployed the sample war in eap-6.1.0.Alpha1, tried to open http://localhost:8080/rf-jee6 and welcome page is displayed, faces servlet took over the control

                          note the last slash added

                           

                          welcome_problem_eap6.png