开发者

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

开发者 https://www.devze.com 2022-12-15 02:28 出处:网络
I have created simple Java Dynamic Web project in Eclipse. I host my project on Glassfish 2.1.1. When I try open p1.jsf page in browser I got following error:

I have created simple Java Dynamic Web project in Eclipse. I host my project on Glassfish 2.1.1. When I try open p1.jsf page in browser I got following error: javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20.

I have no idea how to correct this error...

Here is may p1.jsf definition:

 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
 <%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
 <%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 <html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 <title>Insert title here</title>
 </head>
 <body>
 <f:view>
  <h:outputLabel value="outputLabel"></h:outputLabel>
 </f:view>
 </body>
 </html>

My web.xml:

 <?xml version="1.0" encoding="UTF-8"?>
 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
   <display-name>web4</display-name>
   <welcome-file-list>
     <welcome-file>index.html</welcome-file>
     <welcome-file>index.htm</welcome-file>
     <welcome-file>index.jsp</welcome-file>
     <welcome-file>default.html</welcome-file>
     <welcome-file>default.htm</welcome-file>
     <welcome-file>default.jsp</welcome-file>
   </welcome-file-list>
   <servlet>
     <servlet-name>FacesServlet</servlet-name>
     <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
     <load-on-startup>1</load-on-startup>
   </servlet>
   <servlet-mapping>
     <servlet-name>FacesServlet</servlet-name>
     <url-pattern>*.jsf</url-pattern>
   </servlet-mapping>
 </web-app>

My faces-config.xml:

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

<faces-config
    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-facesconfig_1_2.xsd"
    version="1.2">

</faces-config>

Error details from Glassfish log:

PWC1406: Servlet.service() for servlet FacesServlet threw exception javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20
 org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:860)
 org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723)
 org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:558)
 org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:490)
 org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:382)
 com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
 com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:468)
 com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
 com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
 com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
 com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
 javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
 org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
 org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:873)
 org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723)
 org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:558)
 org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.开发者_如何学Pythonjava:490)
 org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:382)
 com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
 com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:468)
 com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
 com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
 com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
 com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
 javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
 org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
 org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:873)
 org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723)
 org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:558)
 org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:490)
 org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:382)
 com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
 com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:468)
 com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
 com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
 com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
 com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
 javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
 org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
 org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:873)
 org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723)
 org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:558)
 org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:490)
 org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:382)
 com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
 com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:468)
 com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
 com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
 com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
 com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
 javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)


  1. FacesServlet should be mapped on an url-pattern of *.jsf (or anything else other than *.jsp).
  2. No javax.faces.DEFAULT_SUFFIX is needed in web.xml if you already use JSP. The JSP page itself must actually be named pagename.jsp (and thus not pagename.jsf, this is the root cause of the recursive forward calls).
  3. Open the page in the webbrowser using the *.jsf suffix: http://example.com/context/pagename.jsf (and thus not by pagename.jsp, else you would get RuntimeException: FacesContext not found).


This means that recursive internal forwards occur. A few things to observe:

  • make sure you are accessing the page via the right suffix. i.e. http://localhost:8080/app/p1.jsp, and not p1.page - you have mapped the jsf suffix to be .jsp
  • check your navigation rules in your faces-config.xml
  • make sure you have the following context-param defined:

    <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.jsp</param-value>
    </context-param>
    

To summarize - the javax.faces.DEFAULT_SUFFIX determines the file extension under which the page are sought, and the <url-pattern> of the faces-servlet determines the way the jsf pages are accessed by clients (browsers)

0

精彩评论

暂无评论...
验证码 换一张
取 消