Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSF2.2--com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError #45

Open
genlly opened this issue Aug 30, 2019 · 9 comments

Comments

@genlly
Copy link

genlly commented Aug 30, 2019

Dear ran-jit:
Thanks a lot for your contribution! Your tomcat 8 session manager reallys helps me! But it does not work fine in JSF2.2 enviroment, when I use dopost method through the components in the <h:form> , like click a <p:commandlink> or a <p:commandbutton>, when it trigger the request, it throws out an exception in the 29th row of "tomcat.request.session.redis.SessionHandlerValve.invoke", and all the ajax functionalities fails.
The full exception is like this:
31-Aug-2019 00:36:35.144 SEVERE [http-nio-8080-exec-7] com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError javax.faces.application.ViewExpiredException: viewId:/createorder.jsf - can not restore view /createorder.jsf
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:212)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:123)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:100)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at tomcat.request.session.redis.SessionHandlerValve.invoke(SessionHandlerValve.java:29)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1533)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1489)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
I really like your work, and I deelpy hope that is works in a JSF circumstance, thanks again and waiting for your reply!

@ran-jit
Copy link
Owner

ran-jit commented Aug 30, 2019

Hi @genlly,

Which version of the session manager are you using?

@ran-jit
Copy link
Owner

ran-jit commented Aug 30, 2019

Hi @genlly,

I tried reproducing the issue in my local. The session manager is working fine as expected.

Screenshot 2019-08-31 at 12 54 11 AM

PS - test project for your reference.

Please let me know your thoughts on this.

Thanks!

@genlly
Copy link
Author

genlly commented Aug 31, 2019

Thanks ran-jit, I use ran-jit/tomcat-cluster-redis-session-manager3.0.3, and I use viewScoped managed bean, in the request method, as visit from the browser, it's normal, but when you click a <h:commandButton> or a <h:commandlink> in a <h:form>, that's the POST method, it fails and throw out this exception.
Like this: <h:commandButton actionListener="#{Managedbean.Listener(var.Id)}" update="@Form"/>
when you click this button, it doesn't work and throws out the exception. It just like the session was lost and the revoke can't restore the JSF view.

@genlly
Copy link
Author

genlly commented Aug 31, 2019

Something more: it works fine in tomcat7, and leaks in tomcat8:(

@ran-jit
Copy link
Owner

ran-jit commented Aug 31, 2019

Hi @genlly,

By default, HTTP stores the status of the JSF view in the request session.

When the JSF view page is inactive for a long time, Tomcat removes/expires the session values ​​when the session timeout is reached. Now when we try to access the view page, the exception below is thrown, since the view state is removed in session.

Fix: 1
Increase the duration of the session timeout. But the inactive session data will not be removed in Redis cache. This will increase the Redis data complexity.

Configuration (tomcat/conf/web.xml)

<session-config>
    <session-timeout>60</session-timeout>
</session-config>

Fix: 2
Tells the user that the session has expired and request them to refresh the page to perform actions.

Configuration (tomcat/conf/web.xml)

<error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/WEB-INF/errorpages/expired.xhtml</location>
</error-page>

Fix: 3 (Recommended)
Changing the save view state to the client-side.

Configuration (project-resources/webapp/WEB-INF/web.xml)

<context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
</context-param>

FYI - I reproduced the issue and tested with the recommended 3rd fix. Working fine.

I hope this helps!

Thanks!

@genlly
Copy link
Author

genlly commented Aug 31, 2019

Hi @ran-jit ,
That is not a long time inactive, that is nearly everytime you trigger a "post" method, it leaks. It happens just after the page is loaded, and you click a commandbutton, it fails.
And curiously, it works fine in tomcat7, I would like to change to tomcat7 from tomcat8 to solve this issue.

@genlly genlly closed this as completed Sep 2, 2019
@ran-jit
Copy link
Owner

ran-jit commented Sep 2, 2019

Hi @genlly,

Have you resolved this issue? Are any changes required in this session manager?

@genlly
Copy link
Author

genlly commented Sep 2, 2019

Hi, @ran-jit ,
The issue is not solved, I gave up and change my middleware to Tomcat7.0.96 to avoid this issue.

@ran-jit
Copy link
Owner

ran-jit commented Sep 2, 2019

Thanks for the update @genlly.

I am currently on vacation with my family. Will update you as soon as I identify and fix this.

@genlly genlly reopened this Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants