gpt4 book ai didi

jsf - java.lang.StackOverflowError 在 javax.faces.context.FacesContext.getAttributes(FacesContext.java :64)

转载 作者:行者123 更新时间:2023-12-02 17:41:39 26 4
gpt4 key购买 nike

当我点击应用程序 URL (http://localhost:9082/pages/upload.jsf) 时,浏览器上只显示“Error:500 StackOverflowError”。根据我在这个问题上的基础工作,我可以看出这可能是由于某些递归问题造成的。

并且我的应用部署的服务器是WAS 8

请有人帮我解决这个问题。我知道这很模糊,如果我需要分享任何内容,请告诉我。 (例如,控制台上的错误消息等)

at javax.faces.context.FacesContext.getAttributes(FacesContext.java:64)
at javax.faces.context.FacesContext.getAttributes(FacesContext.java:64)
[the same line repeated many times]
at javax.faces.context.FacesContext.getAttributes(FacesContext.java:64)
at javax.faces.context.FacesContext.getAttributes(FacesContext.java:64)
at org.apache.myfaces.application.ResourceHandlerImpl.isResourceRequest(ResourceHandlerImpl.java:416)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:180)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1188)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:763)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:454)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:125)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:92)
at com.lmig.putt.customComponents.UploadFilter.doFilter(UploadFilter.java:61)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:192)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:89)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:919)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1016)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3703)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:962)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture$1.run(AsyncChannelFuture.java:205)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1659)

` 这是我在点击 URL 后在控制台上发现的错误消息。请帮助我,因为我发现它是全新的,而且很难破解

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>PUTT</display-name>

<context-param>
<param-name>log4ConfigLocation</param-name>
<param-value>/WEB-INF/classes/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/application-context.xml</param-value>
</context-param>
<!-- Log4jConfigListener also tries to
set the webAppRootKey. solve this by adding the following statements in web.xml -->
<context-param>
<param-name>log4jExposeWebAppRoot</param-name>
<param-value>false</param-value>
</context-param>


<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>



<jsp-config>
<taglib>
<taglib-uri>http://www.lmig.com/PUTT/upload</taglib-uri>
<taglib-location>/WEB-INF/upload.tld</taglib-location>
</taglib>
</jsp-config>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<filter>
<filter-name>Upload Filter</filter-name>
<filter-class>com.lmig.putt.customComponents.UploadFilter</filter-class>
<init-param>
<param-name>com.lmig.putt.customComponents.UploadFilter.sizeThreshold</param-name>
<param-value>1024</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Upload Filter</filter-name>
<url-pattern>/pages/upload.jsf</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>Upload Filter</filter-name>
<url-pattern>/pages/upload.jsp</url-pattern>
</filter-mapping>

<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>
javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<resource-ref>
<description>DataSource</description>
<res-ref-name>jdbc/db2DS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

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

</web-app>

faces-config.xml

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

<!-- <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xi="http://www.w3.org/2001/XInclude"
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"> -->

<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_2_0.xsd"
version="2.0">



.

.
.
.
</faces-config>

最佳答案

基于 MyFaces 2.0.5 源代码,堆栈跟踪中的行号匹配,FacesContext#getAttributes()看起来像这样:

55    public Map<Object, Object> getAttributes()
56 {
57 FacesContext ctx = _firstInstance.get();
58
59 if (ctx == null)
60 {
61 throw new UnsupportedOperationException();
62 }
63
64 return ctx.getAttributes();
65 }

换句话说,_firstInstance.get() 在您的特定情况下错误地返回了当前实例。这表明在其他地方的代码中的某个点,JSF 内部代码中发生了以下操作:

FacesContext.setCurrentInstance(FacesContext.getCurrentInstance());

这是不对的。 FacesContext 的当前实例不应引用其自身。它只会导致每次访问自身的无限循环,正如堆栈跟踪所证明的那样。

此外,您显然已成功部署 Web 应用程序,并在 web.xml

中使用特定于 Mojarra 的监听器
 <listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>

建议您在 webapp 的运行时类路径中有 MyFaces 的竞争对手 Mojarra。换句话说,您正在混合两个完全不同的 JSF 实现!这绝对是不对的。这就像在一台汽车发动机中混合汽油和柴油。 IBM WebSphere 捆绑了 MyFaces。您应该删除任何与 Mojarra 相关的 JAR 文件(jsf-api.jarjsf-impl.jar 和/或 javax。 faces.jar)、配置条目(com.sun.faces.*)和来自您的 webapp 的其他工件。它们与 MyFaces 冲突。

另见:

关于jsf - java.lang.StackOverflowError 在 javax.faces.context.FacesContext.getAttributes(FacesContext.java :64),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19930448/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com