webtier@glassfish.java.net

Re: [webtier] Help with PWC1232: Exceeded maximum depth for nested request dispatches

From: <webtier_at_javadesktop.org>
Date: Tue, 11 May 2010 10:03:45 PDT

I found the matter that couse the recursion. If i understand right the documentation, setting the parameter javax.faces.FACELETS_SUFFIX it shold specify an alternate suffix for Facelet based XHTML pages.
For example if i want that pages with extension "*.jsf" are processed from Faces Servlet i have to set:
    javax.faces.FACELETS_SUFFIX = ".jsf"


So calling a web page "http://bla/myApp/index.jsf , the application should redirect
the request to facelet view handler.

The full stack of the problem is:

[.....................................]

     at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:802)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:664)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:497)
        at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:468)
        at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:364)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:314)
        at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:542)
        at com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:355)
        at com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:130)
        at com.sun.faces.application.view.JspViewHandlingStrategy.renderView(JspViewHandlingStrategy.java:170)
        at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
        at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
        at it.ciao.MappingViewHandler.renderView(MappingViewHandler.java:86)
        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
        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:313)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
        at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:802)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:664)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:497)
        at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:468)
        at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:364)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:314)
        at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:542)
        at com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:355)
        at com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:130)
        at com.sun.faces.application.view.JspViewHandlingStrategy.renderView(JspViewHandlingStrategy.java:170)
        at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
        at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
        at it.ciao.MappingViewHandler.renderView(MappingViewHandler.java:86)
        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
        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:313)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
        at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:802)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:664)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:497)
        at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:468)
        at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:364)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:314)
        at it.ciao.MappingFilter.doFilter(MappingFilter.java:114)

[..................]


From what i saw, the page is processed as a JSP page, com.sun.faces.application.view.JspViewHandlingStrategy manage it.
Couse JspViewHandlingStrategy manage jsp at the end of calls on method at com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:355) it calls at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:542) and go into an infinite loop couse into the method
 com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:130)

the condition:

        if (Util.isViewPopulated(context, view)) {
            return;
        }
is never satisfied.

I don't know how it full work, so i can't go inside more, but i did a debug to see why
JspViewHandlingStrategy is called instead of FaceletViewHandlingStrategy.

The method: com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)

ask to JspViewHandlingStrategy and FaceletViewHandlingStrategy if they can handle the page.
It's called on the method renderView:

vdlFactory.getViewDeclarationLanguage(viewToRender.getViewId()) to obtain the right
ViewHandlingStrategy.


When it is asked to FaceletViewHandlingStrategy if it can manage a page with an extension specified in javax.faces.FACELETS_SUFFIX it do a check in the
method:
     public boolean handlesViewId(String viewId);

The method is the follow:

    @Override
    public boolean handlesViewId(String viewId) {
         if (viewId != null) {
            // If there's no extensions array or prefixes array, then
            // assume defaults. .xhtml extension is handled by
            // the FaceletViewHandler and .jsp will be handled by
            // the JSP view handler
            if ((extensionsArray == null) && (prefixesArray == null)) {
                return (viewId.endsWith(ViewHandler.DEFAULT_FACELETS_SUFFIX));
            }

            if (extensionsArray != null) {
                for (String extension : extensionsArray) {
                    if (viewId.endsWith(extension)) {
                        return true;
                    }
                }
            }

            if (prefixesArray != null) {
                for (String prefix : prefixesArray) {
                    if (viewId.startsWith(prefix)) {
                        return true;
                    }
                }
            }
        }

        return false;
    }

The problem is that extensionsArray and prefixesArray are null, altougth extensionsArray should ,if i am supposing well, contains extensions we specify in
javax.faces.FACELETS_SUFFIX.

-->

Now a check to how extensionsArray is initialized. It is done in the method:
protected void initializeMappings() (line 775) of the FaceletViewHandlingStrategy class.
In the first line there is:
String viewMappings = webConfig.getOptionValue(FaceletsViewMappings);

That should retrive the init parameters that specify the extensions we set.

-->
I go to what correspond FaceletsViewMappings:

it is:
          FaceletsViewMappings(
              ViewHandler.FACELETS_VIEW_MAPPINGS_PARAM_NAME,
              ""
        )

so it retrive only extensions specified in the Context param:
 
        * javax.faces.FACELETS_VIEW_MAPPINGS

And the parameter javax.faces.FACELETS_SUFFIX is totally ignored.

So to have things work , the extension must be specified in the parameter javax.faces.FACELETS_VIEW_MAPPINGS.

Now a question, is this correct? From what i read on specifications, javax.faces.FACELETS_SUFFIX should be an alternative suffix to XHTML pages, so
i supposed it sohuld work to have FaceletViewHandlingStrategy processing pages that has extensions specified with it?
[Message sent by forum member 'tapdani']

http://forums.java.net/jive/thread.jspa?messageID=469405