1

我只是想尝试一下使用 Tomcat 6.0 的 JSF 2.0 (MyFaces 2.0)。我对 JSF 完全陌生。我只是test.jsf在应用程序根目录中放置了一个静态 xhtml。当请求 URL 时,StackOverflowError总是会抛出 a:

 java.lang.StackOverflowError
 at org.apache.catalina.core.ApplicationHttpRequest$AttributeNamesEnumerator.<init>(ApplicationHttpRequest.java:904)
 at org.apache.catalina.core.ApplicationHttpRequest.getAttributeNames(ApplicationHttpRequest.java:243)
 at org.apache.catalina.core.ApplicationHttpRequest$AttributeNamesEnumerator.<init>(ApplicationHttpRequest.java:905)
 at org.apache.catalina.core.ApplicationHttpRequest.getAttributeNames(ApplicationHttpRequest.java:243)
 at org.apache.catalina.core.ApplicationHttpRequest$AttributeNamesEnumerator.<init>(ApplicationHttpRequest.java:905)

(重复了很多次,但后来:)

 at org.apache.catalina.core.ApplicationHttpRequest$AttributeNamesEnumerator.<init>(ApplicationHttpRequest.java:905)
 at org.apache.catalina.core.ApplicationHttpRequest.getAttributeNames(ApplicationHttpRequest.java:243)
 at org.apache.myfaces.context.servlet.RequestMap.getAttributeNames(RequestMap.java:66)
 at org.apache.myfaces.util.AbstractAttributeMap.isEmpty(AbstractAttributeMap.java:100)
 at org.apache.myfaces.renderkit.ErrorPageWriter._writeVariables(ErrorPageWriter.java:558)
 at org.apache.myfaces.renderkit.ErrorPageWriter._writeVariables(ErrorPageWriter.java:538)
 at org.apache.myfaces.renderkit.ErrorPageWriter.debugHtml(ErrorPageWriter.java:259)
 at org.apache.myfaces.renderkit.ErrorPageWriter.debugHtml(ErrorPageWriter.java:221)
 at org.apache.myfaces.renderkit.ErrorPageWriter.handleThrowable(ErrorPageWriter.java:384)
 at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:102)
 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
 at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
 at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
 at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
 at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:439)
 at org.apache.myfaces.view.jsp.JspViewDeclarationLanguage.buildView(JspViewDeclarationLanguage.java:115)
 at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:103)
 at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:207)
 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:191)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
 at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
 at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
 at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
 at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:439)
 at org.apache.myfaces.view.jsp.JspViewDeclarationLanguage.buildView(JspViewDeclarationLanguage.java:115)
 at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:103)
 at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:207)
 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:191)

(也重复了很多次……)

我做错了什么?

4

1 回答 1

3

HTTP servlet 请求期间表示 servlet/过滤器映射中的StackOverflowError无限递归。你的FacesServlet映射是怎样的?它应该被映射为监听一个url-pattern不是*.jsf监听(这是初学者的常见错误)。否则它将递归地调用自己。实际文件应命名为. 您只需像在 URL 中那样调用它。请仔细查阅/参考 JSF 2.0书籍/教程/文档如何正确配置/使用 JSF。 *.xhtml*.xhtml*.jsf

于 2010-04-23T17:00:09.973 回答