1

I'm migrating an existing app from Tomcat to GAE. When testing locally, the xhtml pages are loaded as static pages. All processing is bypassed including my filter. However, if I reference a page that doesn't exist, my security filter forwards the request to the login.xhtml and the JSF/facelet renders fine.

Any idea why the xhtml pages are getting processed?

Other integrations: eclipse Helios, gae 1.6.5, maven (eclipse/m2), moharra 2.0.9, richfaces 4.2.0, spring 3.1.1

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 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_3_0.xsd">

    <!-- https://community.jboss.org/wiki/HowToUseRichFaces40WithGoogleAppEngine -->
   <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>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
    </context-param>


 <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
 </context-param>

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

<listener>
  <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>


 <filter>
  <filter-name>SecurityFilter</filter-name>
  <filter-class>com.xyz.web.filter.SecurityFilter</filter-class>
 </filter>
 <filter-mapping>
  <filter-name>SecurityFilter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>

 <servlet>
  <servlet-name>Faces Servlet</servlet-name>
  <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
 </servlet>

 <servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.xhtml</url-pattern>
 </servlet-mapping>

    <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>

</web-app>

Update: It works if I add the following mapping and refer to the page with .jsf extension. Referring to the .xhtml directly, still loads the source. Is it typical configuration to refer to .jsf extension for a .xhtml? If so, how do you configure the app so the source isn't available when accessed via .xhtml?

 <servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.jsf</url-pattern>
 </servlet-mapping>
s_t_e_v_e
  • 2,496
  • 3
  • 31
  • 35
  • look for mkyoung fine tutorials.. might find something over there... https://www.google.com/search?q=gae+mkyoung+jsf&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a – Daniel May 19 '12 at 19:53
  • 1
    http://stackoverflow.com/questions/5675271/how-to-avoid-user-access-to-xhtml-page-in-jsf ? – Daniel May 20 '12 at 15:30
  • Thanks again. One remaining question then is why the .xhtml url-pattern doesn't work on GAE as BalusC recommends in that thread. I'll revise the question once more and keep it open. – s_t_e_v_e May 20 '12 at 18:22
  • GAE runs on Jetty server do some googling , might find some info, but do double check before... cause you might missed something... – Daniel May 20 '12 at 19:16
  • Will do. You've already been my personal google assistant twice now. I'll take it from here. :) – s_t_e_v_e May 20 '12 at 20:27

1 Answers1

4

If I correctly understand your needs, you should add

<static-files>
    <exclude path="/**.xhtml" />
</static-files>

in appengine-web.xml

If you skip this, your web browser will get reply from "static file server", not from JSF.

mk761203
  • 76
  • 3