ServletException: Exceeded maximum depth for nested request dispatches: 20

Splash Forums PrettyFaces Users ServletException: Exceeded maximum depth for nested request dispatches: 20

This topic contains 12 replies, has 3 voices, and was last updated by  jllado 4 years, 5 months ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #19266

    jllado
    Participant

    Hello!

    Output when webapp is deployed:

    INFO: PrettyFilter starting up...
    INFO: PrettyFilter initialized.

    Then I open my site in web browser with path that ends by ‘projectName/’

    and it gives me the following in server.log:

    At first very very many times my phase listener prints that lifecycle starts and ends.

    Then there is finally the error:

    [#|2012-12-28T15:41:08.484+0200|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=83;_ThreadName=Thread-8;|ApplicationDispatcher[/javahelp] PWC1231: Servlet.service() for servlet Faces Servlet threw exception
    javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20
    at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:794)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:671)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:505)
    at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:476)
    at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:355)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:305)
    at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:546)
    at com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:364)
    at com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:154)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:100)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:145)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:807)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:671)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:505)
    at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:476)
    at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:355)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:305)
    at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:546)
    at com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:364)
    at com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:154)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:100)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:145)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:807)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:671)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:505)
    at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:476)
    at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:355)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:305)
    at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:546)
    at com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:364)
    at com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:154)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:100)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

    This stacktrace is so long that I print only part of it.

    People told me that the problem is rather in prettyfaces.

    Important:

    I don’t get this error only if I type path that ends by ‘/’.

    I get this error if I type path that ends with ‘.jsf’.

    My FacesServlet mapping is

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

    However if I type the same path that ends by ‘.xhtml’ than pretty-config.xml works correctly

    and redirects me to 301.

    Thank you!

    #23351

    Could you perhaps share your full web.xml and pretty-config.xml?

    So you say that initially the web app works fine but later on for some URL it fails with this error? For which URL does it fail?

    Looking at the stacktrace it doesn’t seem like the error is caused by PrettyFaces. Actually the JSF implementation performs the dispatch that is looping.

    It would be important to know which URL it is that produces the error.

    #23352

    Looks like this could be caused by some JSP <j:forward> or <j:include> tags that call into the same page they came from.

    #23353

    jllado
    Participant

    Thank you for replies!

    I have no <j:forward> or <j:include>. I use only Facelet for my view.

    I did not have this problem before because I used *.xhtml mapping for FacesServlet.

    As soon as I changed FacesServlet mapping to *.jsf this error occurred.

    Very important is that I have this error NOT when I type in browser

    http://localhost:/projectName/mypage.xhtml

    but when I type :

    http://localhost:/projectName/mypage.jsf

    Second path means that the url is intercepted by FacesServlet and appropriate view is constructed.

    Exactly this second url causes the error .

    javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20

    Before the error arises I see my phase listener goes many times through lifecycle because I log each phase!

    Probably FacesServlet redirects my page with url that ends by .jsf and thus FacesServlet again intercepts url which was sent by FacesServlet. Probably it does not change mypage.jsf to mypage.xhtml.

    This causes the lifecycle to run 20 times.

    Probably the error not due to PrettyFaces but due to FacesServlet.

    Please tell me what can I do here?

    P.S. I have this error also when I type ‘http://localhost:8080/projectName/&#8217;

    pretty-config.xml does not have pattern ‘/’ to intercept this url.

    Thank you!

    #23354

    jllado
    Participant

    My 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">
    <description>My first real web site where you get help on java</description>
    <display-name>JavaHelp web site</display-name>
    <distributable/>
    <context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
    </context-param>
    <context-param>
    <param-name>com.sun.faces.validateXml</param-name>
    <param-value>true</param-value>
    </context-param>
    <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
    </context-param>
    <context-param>
    <param-name>javax.faces.FULL_STATE_SAVING_VIEW_IDS</param-name>
    <param-value>/user/userProfile.jsf,/register.jsf</param-value>
    </context-param>
    <context-param>
    <param-name>javax.faces.FACELETS_SUFFIX</param-name>
    <param-value>*.jsf</param-value>
    </context-param>
    <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>*.jsf</param-value>
    </context-param>
    <context-param>
    <param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>
    <param-value>true</param-value>
    </context-param>
    <context-param>
    <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
    <param-value>true</param-value>
    </context-param>
    <context-param>
    <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
    <param-value>/WEB-INF/JavaHelp-taglib.xml</param-value>
    </context-param>
    <mime-mapping>
    <extension>jpeg</extension>
    <mime-type>image/jpeg</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>png</extension>
    <mime-type>image/png</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>gif</extension>
    <mime-type>image/gif</mime-type>
    </mime-mapping>

    <filter>
    <filter-name>Upload Filter</filter-name>
    <filter-class>com.javahelp.util.cc.UploadFilter</filter-class>
    <init-param>
    <param-name>sizeThreshold</param-name>
    <param-value>1024</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>Upload Filter</filter-name>
    <url-pattern>/register.jsf</url-pattern>
    </filter-mapping>

    <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>
    <session-config>
    <session-timeout>
    30
    </session-timeout>
    <cookie-config>
    <name>SESSIONID</name>
    </cookie-config>
    </session-config>
    <welcome-file-list>
    <welcome-file>/index.jsf</welcome-file>
    </welcome-file-list>

    <login-config>
    <auth-method>FORM</auth-method>
    <realm-name>javahelpRealm</realm-name>
    <form-login-config>
    <form-login-page>/WEB-INF/resources/login.jsf</form-login-page>
    <form-error-page>/WEB-INF/resources/loginError.jsf</form-error-page>
    </form-login-config>
    </login-config>
    <security-constraint>
    <display-name>UserConstraint</display-name>
    <web-resource-collection>
    <web-resource-name>Secure Pages</web-resource-name>
    <description>User area</description>
    <url-pattern>/user/*</url-pattern>
    <url-pattern>/login</url-pattern>
    <url-pattern>/profile</url-pattern>
    </web-resource-collection>
    <auth-constraint>
    <role-name>USER</role-name>
    </auth-constraint>
    <user-data-constraint>
    <description>highest supported transport security level</description>
    <!--<transport-guarantee>CONFIDENTIAL</transport-guarantee>-->
    <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
    </security-constraint>
    <security-constraint>
    <display-name>AdminConstraint</display-name>
    <web-resource-collection>
    <web-resource-name>Secure Pages</web-resource-name>
    <description>Administration area</description>
    <url-pattern>/admin/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
    <role-name>ADMINISTRATOR</role-name>
    </auth-constraint>
    <user-data-constraint>
    <description>highest supported transport security level</description>
    <!--<transport-guarantee>CONFIDENTIAL</transport-guarantee>-->
    <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
    </security-constraint>
    <security-role>
    <description/>
    <role-name>ADMINISTRATOR</role-name>
    </security-role>
    <security-role>
    <description/>
    <role-name>USER</role-name>
    </security-role>
    <env-entry>
    <description>Base URL as seen in the user's browser.</description>
    <env-entry-name>javahelp/uploadsDir</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>C://glassfish3/glassfish/domains/domain1/lib/JavaHelp/uploads</env-entry-value>
    </env-entry>
    <env-entry>
    <description>Base URL as seen in the user's browser.</description>
    <env-entry-name>javahelp/StickerList</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>C://glassfish3/glassfish/domains/domain1/lib/JavaHelp/other/StickerList.list</env-entry-value>
    </env-entry>
    <error-page>
    <error-code>403</error-code>
    <location>/WEB-INF/resources/forbidden.jsf</location>
    </error-page>
    <error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/index.jsf</location>
    </error-page>
    <resource-ref>
    <description>this references to factory of javax.mail.Session instances</description>
    <res-ref-name>mail/javahelpSession</res-ref-name>
    <res-type>javax.mail.Session</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    <ejb-local-ref>
    <ejb-ref-name>mailerBean</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <local>com.javahelp.util.MailerBean</local>
    </ejb-local-ref>
    </web-app>

    My pretty-config.xml

    <pretty-config xmlns="http://ocpsoft.com/prettyfaces/3.3.3"
    xmlns:xsi="http: / www.w3.org / XMLSchema-instance"
    xsi:schemaLocation="http://ocpsoft.com/prettyfaces/3.3.3 http://ocpsoft.com/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.3.xsd">
    <rewrite match="/index.xhtml" substitute="/resource_not_found"
    redirect="301" />
    <rewrite match="/register.xhtml" substitute="/resource_not_found"
    redirect="301" />
    <rewrite match="/user/userProfile.xhtml" substitute="/resource_not_found"
    redirect="301" />
    <rewrite match="/forums.xhtml" substitute="/resource_not_found"
    redirect="301" />
    <rewrite match="/forum.xhtml" substitute="/resource_not_found"
    redirect="301" />
    <rewrite match="/topic.xhtml" substitute="/resource_not_found"
    redirect="301" />

    <url-mapping id="home">
    <pattern value="/home" />
    <view-id value="/index.jsf" />
    <action>#{user.notifyUserOfActivation}</action>
    </url-mapping>

    <url-mapping id="login">
    <pattern value="/login" />
    <view-id value="/index.jsf" />
    <query-param name="currentPage">#{user.currentPage}</query-param>
    <action>#{user.redirectLoggedInUser}</action>
    </url-mapping>

    <url-mapping id="logout">
    <pattern value="/guest" />
    <view-id value="/index.jsf" />
    <action>#{user.logout}</action>
    </url-mapping>

    <url-mapping id="register" onPostback="false">
    <pattern value="/register" />
    <view-id value="/register.jsf" />
    </url-mapping>

    <url-mapping id="newUser">
    <pattern value="/welcome" />
    <view-id value="/register.jsf" />
    <action>#{registerBacking.create}</action>
    </url-mapping>

    <url-mapping id="profile" onPostback="false">
    <pattern value="/profile" />
    <view-id value="/user/userProfile.jsf" />
    </url-mapping>

    <url-mapping id="forums">
    <pattern value="/forums" />
    <view-id value="/forums.jsf" />
    </url-mapping>

    <url-mapping id="forum">
    <pattern value="/forum.jsf" />
    <query-param name="forumId" validator="#{forumBacking.validateUrlParameter}"
    onError="pretty:forums">#{forumBacking.currentForum}</query-param>
    <view-id value="/forum.jsf" />
    <action>#{forumBacking.checkForumIdUrlParameter}</action>
    </url-mapping>

    <url-mapping id="topic">
    <pattern value="/topic.jsf" />
    <query-param name="topicId" onPostback="false"
    validator="#{user.validateUrlParameter}" onError="pretty:forums">#{topicBacking.currentTopic}</query-param>
    <view-id value="/topic.jsf" />
    <action>#{topicBacking.checkTopicIdUrlParameter}</action>
    </url-mapping>

    <url-mapping parentId="forums" id="forumTopic">
    <pattern value="/#{forumTopicId}">
    <validate index="0" validator="#{requestScopedBean.validateUrlParameters}"
    onError="pretty:forums" />
    </pattern>
    <view-id value="#{requestScopedBean.targetPage}" />
    </url-mapping>
    </pretty-config>

    #23355

    Could you try to remove the javax.faces.FACELETS_SUFFIX and javax.faces.DEFAULT_SUFFIX entries from your web.xml?

    #23356

    jllado
    Participant

    After I removed

    <!--   <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>*.jsf</param-value>
    </context-param> -->

    the result is XML tree with my jsf elements like in source .xhtml page. At the top of google chrome:

    This XML file does not appear to have any style information associated with it. The document tree is shown below.

    CSS files are registered correctly.

    But after I retrieved above mapping I again see the same xception:

    javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20

    The follwing context-param does not make any difference:

    <!--     <context-param>
    <param-name>javax.faces.FACELETS_SUFFIX</param-name>
    <param-value>*.jsf</param-value>
    </context-param> -->

    #23357

    jllado
    Participant

    If I call

    http://localhost:8080/projectName/index.jsf

    I have no XML tree but my text rendered in browser without any styles.

    CSS is not working !

    #23358

    jllado
    Participant

    Also I found that it is not the problem of charset as I tried both UTF-8 and ISO-8859-1. They both render XML tree

    #23359

    I’ve no idea what is going wrong with your app. But one thing is very strange: In the stacktrace you posted I’m seeing JspViewHandlingStrategy. This is strange because I would expect FaceletViewHandlingStrategy instead because you wrote that you are using Facelets. The JspViewHandlingStrategy seems to think that you are using JSPs. Therefore it forwards the incoming request to the JSP. And exactly this is causing the loop.

    It seems like there are other people on the net having a similar problem. You should have a look here:

    http://www.ninthavenue.com.au/blog/stackoverflow-exception-upgrading-to-jsf-2%2e

    http://stackoverflow.com/questions/2000436/stackoverflow-when-running-jsf

    #23360

    jllado
    Participant

    Thank you for response.

    I have visited those links but I did not pay attention to these comments of BalusC:

    Oh, you’re using Facelets. I didn’t expect that it would pass through the JSP view handler then.

    .jsf mapping is intercepted exactly by JSP ViewHandler but not by Facelets ViewHandler.

    This is a good question to Tim Holloway!

    #23361

    Oh sorry, I saw one of the links I posted was broken. That’s the correct one:

    http://www.ninthavenue.com.au/blog/stackoverflow-exception-upgrading-to-jsf-2%2e

    That’s also the blog post that exactly describes your problem and that also tells you how to fix it.

    Christian

    #23362

    jllado
    Participant

    I am the main cause of problems.

    I set the context-param in web.xml that disabled Facelet View Handler :

    <context-param>
    <param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>
    <param-value>true</param-value>
    </context-param>

    After I removed this great parameter everything is back OK with FacesServlet mapping *.jsf

    Thank you for replies!

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.

Comments are closed.