1

I use a4j:poll to keep session alive but after some idle time i get "View could not be restored" error. I believe poll is creating views in background and after it reaches limit of 15(?) exception is thrown.

<h:form>
    <a4j:poll id="poll" interval="30000"/>
</h:form>

web.xml:

<session-config>
    <session-timeout>1</session-timeout>
    <cookie-config>
        <secure>true</secure>
    </cookie-config>
    <tracking-mode>COOKIE</tracking-mode>
</session-config>

BalusC said: "So, it will only happen when you've manually set that limit way too low, or that you're continuously creating new views in background (e.g. by a badly implemented poll)." in: javax.faces.application.ViewExpiredException: View could not be restored

and I believe it is my problem but i have no diea how to make it right :(

Community
  • 1
  • 1
jerzey
  • 23
  • 4
  • have you tried assigning an id to the form? perhaps the auto-generated id is causing no views to increase – DaveB Apr 14 '16 at 15:22

1 Answers1

1

Are you sure that this was the complete scenario that reproduces the problem? In that case, the problem is your session-timeout that you have set to 1 second. If that was not your case, edit your question.

Another problem that i have found is a a4j:poll inside a multipart form.

<h:form enctype="multipart/form-data">
    <a4j:poll id="poll" interval="30000"/>
</h:form>

Avoid this, It creates a new View ID on every poll request.

On each ajax request a View ID is returned, that is fine as long as the View ID is always the same. If you get a new View ID in each request, then there is a problem with the ajax request in your page.

tak3shi
  • 2,305
  • 1
  • 20
  • 33