myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leonardo Uribe <lu4...@gmail.com>
Subject Re: ViewExpiredException, but session hasn't timed out
Date Thu, 10 Apr 2014 15:16:55 GMT
Hi

I see, now I get it. By default MyFaces always renders the view state
field at the form end. To solve your problem, you need to render it at
the beginning of the form.

JSF spec javadoc for h:form says this:

"... Call ViewHandler.writeState() before the the close of the "form"
element. Render all the necessary hidden fields for all commandLink
instances in the page just before the close of the "form" element.
..."

What happen if we call it at the beginning of the form? there is a
buffer that takes the response to inject the view state token before
the end of the request, so you'll get an small increase of memory
usage if you are using client side state saving, but besides that
nothing else. This is an improvement/new feature, not a bug, so please
create an issue in MyFaces issue tracker as improvement.

regards,

Leonardo



2014-04-10 14:05 GMT+02:00 Felipe Jaekel <fkjaekel@gmail.com>:
> It's necessary to have a slow internet connection to reproduce this, so I
> can't test locally. While the page is loading the user hits a command
> button. As the page is still loading, I guess the view state is not created
> yet, so viewHandler.restoreView(facesContext, viewId) returns null.
>
> Thanks for the suggestion. I'll give it try, but according to the component
> documentation, using it for this case feels more like a workaround than a
> solution, so I'd like to see if there are more options.
>
>
> 2014-04-09 14:48 GMT-03:00 Howard W. Smith, Jr. <smithh032772@gmail.com>:
>
>> Wow, you're using Shiro.
>>
>> Would be nice to have a list of steps how you duplicate this in your app,
>> definitely and always.
>>
>> I definitely suggest you use OmniFaces restore view component to avoid this
>> exception.
>>  On Apr 9, 2014 1:41 PM, "Felipe Jaekel" <fkjaekel@gmail.com> wrote:
>>
>> > I'm getting view expired exceptions if the user tries to perform an
>> action
>> > in a page that isn't fully loaded.
>> >
>> > javax.faces.application.ViewExpiredException: /page/plano/plano.jsfNo
>> > saved view state could be found for the view identifier:
>> > /page/plano/plano.jsf
>> >         at
>> >
>> org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:181)
>> >
>> >
>> > Looking at RestoreViewExceutor source code we have this:
>> >
>> >
>> >                     if (facesContext.getResponseComplete())
>> >                     {
>> >                         // If the view handler cannot restore the view
>> > and the response
>> >                         // is complete, it can be an error or some
>> > logic in restoreView.
>> >                         return true;
>> >                     }
>> >                     else
>> >                     {
>> >                         // If the return from
>> > ViewHandler.restoreView() is null, throw a ViewExpiredException with
>> > an
>> >                         // appropriate error message.
>> >                         throw new ViewExpiredException("No saved view
>> > state could be found for the view identifier: " + viewId, viewId);
>> >                     }
>> >                 }
>> >
>> >
>> > Page hasn't fully loaded yet, so facesContext.getResponseComplete() is
>> > returning false, but isn't there a way to avoid this? Page gets unusable
>> > after the VEE is thrown.
>> >
>> >
>> > Thanks in advance,
>> >
>> > Phillip
>> >
>> >
>> > Full stackTrace:
>> >
>> > javax.faces.application.ViewExpiredException: /page/plano/plano.jsfNo
>> > saved view state could be found for the view identifier:
>> > /page/plano/plano.jsf
>> >         at
>> >
>> org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:181)
>> >         at
>> >
>> org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:196)
>> >         at
>> >
>> org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:143)
>> >         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
>> >         at
>> >
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
>> >         at
>> >
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>> >         at
>> >
>> org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:98)
>> >         at
>> >
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
>> >         at
>> >
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>> >         at
>> > org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
>> >         at
>> >
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
>> >         at
>> >
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>> >         at
>> >
>> org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
>> >         at
>> >
>> org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
>> >         at
>> >
>> org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
>> >         at
>> >
>> org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
>> >         at
>> >
>> org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
>> >         at
>> >
>> org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
>> >         at
>> >
>> org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
>> >         at
>> >
>> org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
>> >         at
>> >
>> org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
>> >         at
>> >
>> org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
>> >         at
>> >
>> org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
>> >         at
>> >
>> org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
>> >         at
>> >
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
>> >         at
>> >
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>> >         at
>> >
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
>> >         at
>> >
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
>> >         at
>> >
>> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
>> >         at
>> >
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
>> >         at
>> >
>> com.googlecode.psiprobe.Tomcat70AgentValve.invoke(Tomcat70AgentValve.java:38)
>> >         at
>> >
>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
>> >         at
>> > org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
>> >         at
>> >
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
>> >         at
>> >
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
>> >         at
>> >
>> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
>> >         at
>> >
>> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
>> >         at
>> >
>> org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
>> >         at
>> >
>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>> >         at
>> >
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>> >         at java.lang.Thread.run(Thread.java:744)
>> >
>>

Mime
View raw message