java FacesMessage 错误渲染视图

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7779874/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 21:25:37  来源:igfitidea点击:

FacesMessage error rendering view

javamaven-2jsf-2glassfishprimefaces

提问by Mounir

I have this a when launching(clean build and run) my JavaEE web application :

我在启动(清理构建并运行)我的 JavaEE Web 应用程序时有这个:

SEVERE: Error Rendering View[/TV/Admin3B/Monitoring/AjoutSpots.xhtml]
java.lang.IllegalStateException: PWC3999: Cannot create a session after the response has been committed
    at org.apache.catalina.connector.Request.doGetSession(Request.java:2880)
    at org.apache.catalina.connector.Request.getSession(Request.java:2577)
    at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:920)
    at com.sun.faces.context.ExternalContextImpl.getSession(ExternalContextImpl.java:155)
    at com.sun.faces.renderkit.ServerSideStateHelper.writeState(ServerSideStateHelper.java:175)
    at com.sun.faces.renderkit.ResponseStateManagerImpl.writeState(ResponseStateManagerImpl.java:122)
    at com.sun.faces.application.StateManagerImpl.writeState(StateManagerImpl.java:166)
        at com.sun.faces.application.view.WriteBehindStateWriter.flushToWriter(WriteBehindStateWriter.java:225)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:418)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662)

I print my FacesMessagewith <p:growl />when I remove it and I reload the page and insert it again the problem was solved , but when I relaunch the application this bug is thrown again. I don't have any idea about this.

打印我的FacesMessage<p:growl />当我删除它,我重新加载页面并重新插入的问题解决了,但是当我重新启动应用程序这个错误再次抛出。我对此没有任何想法。

Thanks

谢谢

Mounir

穆尼尔

回答by BalusC

This is a known bug in one of the latest Mojarra versions. See also issue 2215. This will occur when the response is larger than the default response buffer and thus causes a commit of the response. However, when after that point a view or session scoped managed bean needs to be created and the session hasn't been created yet, then the session creation will fail because the response is already committed. When a session is to be created the servletcontainer namely needs to set a cookie on the response header. This isn't possible anymore when the response headers are already been sent (committed).

这是最新 Mojarra 版本之一中的已知错误。另见第 2215 期。当响应大于默认响应缓冲区并因此导致响应提交时,就会发生这种情况。但是,在此之后需要创建视图或会话范围的受管 bean 并且尚未创建会话时,会话创建将失败,因为响应已经提交。创建会话时,servletcontainer 需要在响应头上设置 cookie。当响应头已经发送(提交)时,这不再可能。

Until the Mojarra guys fix it so that you can upgrade, one of the workarounds is to create the session yourself with help of a Filterwhich runs right before the FacesServletdoes its job.

在 Mojarra 人员修复它以便您可以升级之前,其中一种解决方法是FilterFacesServlet执行其工作之前运行的帮助下自己创建会话。

回答by Raul Serra

I solved it so: In the file with the function of my button (page.xhtml) I had bad write the ManagedProperty:

我是这样解决的:在具有我的按钮功能的文件(page.xhtml)中,我写错了 ManagedProperty:

@ManagedProperty(value="fileSessionBean") 
... rest code...

I change this for:

我将其更改为:

@ManagedProperty(value="#{fileSessionBean}") 
... rest code ...

This work fine now,

现在这个工作正常,