1

My web app is built on spring boot + spring security + JSF 2.2.12

I have read a lot of posts about the view expired exception, and try to solve it using this proposal.

To be shortly, I have added ?faces-redirect=true to my action methods, added NoCacheFilter to inform browser not cache the dynamic JSF pages. Also I have add expired.xhtml page. Also, I have added custom InvalidSessionStrategy implementation using this sample.

For the case, when I have two tabs in my browser, and perform log out in one tab, and in other I click <p:commandButton which trigger POST request for page navigation, everything works fine, browser redirect me to the login page.

But for case, when I have two tabs in my browser, and in one tab I perform log out and then log in, and in other I click again <p:commandButton, the ViewExpiredException is thrown.

Please, help me to solve this issue. Or tell me what I have missed?

Community
  • 1
  • 1
Hutsul
  • 1,535
  • 4
  • 31
  • 51
  • When you logout, the entire HTTP session associated also gets destroyed (this is the definition of logout). When you login again and then click a command component like a `` in another tab (without refreshing the page which is backed by a view scoped bean), it will not find that view backed by that page in the current newly created HTTP session - Naturally, it has no knowledge of the previous HTTP session which was destroyed in its entirely, when you logged out. – Tiny Dec 29 '15 at 14:05
  • 1
    What you missed is adding an error-handler for the exception, as per your linked question's very complete answer. – Gimby Dec 29 '15 at 14:23
  • 1
    That's an **unavoidable** `ViewExpiredException`, in case that's not clear to you. It should end up in a (nice) error page. Was the [answer](http://stackoverflow.com/questions/3642919/javax-faces-application-viewexpiredexception-view-could-not-be-restored) you found sufficiently helpful to cover that? – BalusC Dec 29 '15 at 14:36
  • "That's an unavoidable ViewExpiredException" - yea, this was clear for me. I suppose, I have missed to add exception handler for ajax requests. – Hutsul Dec 29 '15 at 14:47
  • The exception handler help me. Thanks a lot. – Hutsul Dec 29 '15 at 15:18

0 Answers0