本文介绍了使用Facelets而不是JSP会在javax.servlet.http.HttpServletRequestWrapper.getSession()处导致java.lang.StackOverflowError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我在Eclipse IDE中使用JBoss4.2.当我使用JSP视图技术运行hellojsf程序时,它运行良好.当我尝试使用具有相同组件的Facelets时,出现以下异常:

I am using JBoss4.2 with the eclipse IDE. When I run the hellojsf program using JSP view technology, it works fine. When I try with Facelets usings the same components, I am getting the below exception:

2012-06-20 12:41:30,941 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/HelloJSF].[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
java.lang.StackOverflowError
    at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
    at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:545)
    at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
    at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:545)
    at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
    at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:545)

这是怎么引起的,我该如何解决?

How is this caused and how can I solve it?

推荐答案

FacesServlet已无限循环运行.如果您使用的是旧的JSF 1.2而不是较新的JSF 2.x,并且没有正确配置JSF以使用XHTML而不是JSP,则可能会发生这种情况.当JSF 2.x捆绑了Facelets时,JSF 1.2不支持Facelets.

The FacesServlet has run in an infinite loop. That can happen if you're using old JSF 1.2 instead of newer JSF 2.x and didn't configure JSF properly to use XHTML instead of JSP. JSF 1.2 does not support Facelets while JSF 2.x has Facelets bundled.

如果不能升级到JSF 2.0(作为与Servlet 2.5兼容的容器的JBoss 4.2应该支持),则需要分别安装Facelets1.x.下载 jsf-facelets-1.1.15.jar 放到/WEB-INF/lib中,然后编辑web.xml以告诉JSF使用.xhtml作为默认后缀.

If upgrading to JSF 2.0 is not an option (JBoss 4.2 as being a Servlet 2.5 compatible container should support it), then you need to install Facelets 1.x separately. Download jsf-facelets-1.1.15.jar and drop it in /WEB-INF/lib and edit the web.xml to tell JSF to use .xhtml as default suffix.

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

FacesServlet映射URL模式必须*.xhtml,这将导致其无限循环运行.只需将其保存为*.jsf.

The FacesServlet mapping URL pattern must not be *.xhtml, this would cause it to run in an infinite loop. Just keep it *.jsf.

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
</servlet-mapping>

别忘了在faces-config.xml中配置Facelets视图处理程序.

Further don't forget to configure the Facelets view handler in faces-config.xml.

<application>
    <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
</application>

现在,您可以像使用JSP文件一样使用http://localhost:8080/context/page.jsf常规方式打开Facelets文件,唯一的区别是您应该使用page.xhtml文件而不是page.jsp.

Now you can open Facelets files the usual way by http://localhost:8080/context/page.jsf like as you used for JSP files, with the only difference that you should have a page.xhtml file instead of page.jsp.

使用JSF 2.x时,不需要上下文参数和视图处理程序,因为它们已经是JSF 2.x的默认值.同样,在使用JSF 2.x时,可以将URL模式安全地设置为*.xhtml.

When using JSF 2.x, the context param and view handler are unnecessary as those are the default values for JSF 2.x already. Also when using JSF 2.x, the URL pattern can safely be set to *.xhtml.

  • Facelets 1.x developer documentation
  • Migrating from JSF 1.2 to JSF 2.0

这篇关于使用Facelets而不是JSP会在javax.servlet.http.HttpServletRequestWrapper.getSession()处导致java.lang.StackOverflowError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 01:32