javax.servlet.ServletException:PWC1232:嵌套请求调度的最大深度超过:20

时间:2010-01-02 18:39:50

标签: eclipse jsf glassfish

我在Eclipse中创建了简单的Java Dynamic Web项目。我在Glassfish 2.1.1上托管我的项目。当我在浏览器中尝试打开p1.jsf页面时,出现以下错误: javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20

我不知道如何更正此错误...

以下是p1.jsf定义:

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

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

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

Glassfish日志中的错误详细信息:

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

2 个答案:

答案 0 :(得分:4)

  1. FacesServlet应映射到url-pattern *.jsf(或*.jsp以外的任何其他内容)。
  2. 如果您已经使用JSP,则web.xml中不需要javax.faces.DEFAULT_SUFFIX。 JSP页面本身实际上必须命名为pagename.jsp(因此 pagename.jsf,这是递归转发调用的根本原因。)
  3. 使用*.jsf后缀http://example.com/context/pagename.jsf打开网页浏览器中的页面(pagename.jsp,然后,否则您将获得RuntimeException: FacesContext not found )。

答案 1 :(得分:0)

这意味着会发生递归的内部转发。需要注意的一些事项:

  • 确保您通过正确的后缀访问该页面。即http://localhost:8080/app/p1.jsp,而不是p1.page - 您已将jsf后缀映射为.jsp
  • 检查faces-config.xml
  • 中的导航规则
  • 确保您定义了以下context-param:

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

总结一下 - javax.faces.DEFAULT_SUFFIX确定寻找页面的文件扩展名,faces-servlet的<url-pattern>确定客户端(浏览器)访问jsf页面的方式