Skip to main content

Help with PWC1232: Exceeded maximum depth for nested request dispatches

5 replies [Last post]
cain05
Offline
Joined: 2009-08-25
Points: 0

I'm trying to get a simple JSF 2.0 page to show using Glassfish V3 but I keep getting the following exception:

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

Here's my page index.xhtml under WebContent:

</p>
<p>Title</p>
<p>

and here is my web.xml:

<br />
<?xml version="1.0" encoding="UTF-8"?></p>
<p>  mohrts-web</p>
<p>    index.xhtml</p>
<p>    Faces Servlet<br />
    javax.faces.webapp.FacesServlet<br />
    1</p>
<p>    Faces Servlet<br />
    *.xhtml</p>
<p>    javax.faces.STATE_SAVING_METHOD<br />
    server</p>
<p>

From what I can find on google, it looks like the page is recursively trying to render itself and I have no idea why. I'm telling it to pass .xhtml pages through the Faces Servlet so I don't know why it would get stuck there. Any help would be appreciated. Thanks.

Message was edited by: cain05

Message was edited by: cain05

Message was edited by: cain05

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tapdani
Offline
Joined: 2010-05-07
Points: 0

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?

cain05
Offline
Joined: 2009-08-25
Points: 0

Just an update. If I change the servlet mapping to:

[code]

Faces Servlet
*.jsf

[/code]

I get a blank page. When I view the source the shows the jsf tags which means it didn't go though the faces servlet which is what I would expect. I'm surprised that there's not more replies because I find it hard to believe that no one else has run into this. I'm not trying to do anything complex so I don't understand why it's not working.

tapdani
Offline
Joined: 2010-05-07
Points: 0

Hi, unlucky i have the same problems. Yesterday i posted a question on glassfish forum:

http://forums.java.net/jive/thread.jspa?threadID=148233&tstart=0

I can't find out the problem. I think is like a problem beetween default settings of JSF 2 (that they has on Faces Servlet URL patterns: *.jsf , /faces/* and overlapping settings setted).

I tried to see the source code of mojarra ViewHandler. I found that the substitution of file extensions with the ones speficied in javax.faces.DEFAULT_SUFFIX is executed in the JSF phase of restoreView in the following order:

In MultiViewHandler.java:

- Method "public UIViewRoot restoreView(FacesContext context, String viewId) " of (row 139) call :
- derivePhysicalViewId(context, viewId, false) and it call on row 486 method:
- convertViewId(FacesContext context, String viewId) (row 436)
- or normalizeRequestURI(String uri, String mapping);

I think the problem could be beetween convertViewId and derivePhysicalViewId, couse

derivePhysicalViewId calls Util.getFacesMapping(ctx) that retrive URL Pattern from Faces Servlet:

/**
*

Returns the URL pattern of the
* {@link javax.faces.webapp.FacesServlet} that
* is executing the current request. If there are multiple
* URL patterns, the value returned by
* HttpServletRequest.getServletPath() and
* HttpServletRequest.getPathInfo() is
* used to determine which mapping to return.

* If no mapping can be determined, it most likely means
* that this particular request wasn't dispatched through
* the {@link javax.faces.webapp.FacesServlet}.
*
* @param context the {@link FacesContext} of the current request
*
* @return the URL pattern of the {@link javax.faces.webapp.FacesServlet}
* or null if no mapping can be determined
*
* @throws NullPointerException if context is null
*/
public static String getFacesMapping(FacesContext context);

I think there is some kind of problems in this methods, that do the renaming. But i still have to find out what's wrong.

Can anybody help more to find out what's wrong?

Edward Burns

On 5/4/10 13:35 , webtier@javadesktop.org wrote:
> I'm trying to get a simple JSF 2.0 page to show using Glassfish V3 but I keep getting the following exception:
>
> javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20
>
> Here's my page index.xhtml under WebContent:
>

> From what I can find on google, it looks like the page is recursively trying to render itself and I have no idea why. I'm telling it to pass .xhtml pages through the Faces Servlet so I don't know why it would get stuck there. Any help would be appreciated. Thanks.
> [Message sent by forum member 'cain05']
>

What is the URL you are loading to see this behavior? That, combined
with your web.xml, might tell me more.

Ed Burns JSF spec co-lead and Mojarra implementation lead

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

cain05
Offline
Joined: 2009-08-25
Points: 0

http://localhost:8080/mohrts/index.xhtml. In the application.xml in the EAR I have the context root set as mohrts. I have a similar setup with GF 2.1 and JSF 1.2 and it works fine.

Message was edited by: cain05