title: Wicket - Getting PageExpiredException on AJAX Calls. Regular Pages work just fine
body: <p>We are writing an application using Wicket that uses AJAX. The application has a main window with two iFrames. The first iFrame shows a page with a map (Google Maps). The second iFrame shows a DataTable. </p>
  
  <p>The main window is always visible. There are pages that are opened in their own windows (pop up windows). The windows are reused for the same page, for example link-A will reuse the same pop-up window if one is already open for that link. </p>
  
  <p>The problem that we have is that when we start ‘combining’ AJAX calls with loading new pages we start getting <code>PageExpiredException</code>-s for the AJAX calls. Loading Pages (No AJAX) works fine, the AJAX calls are the problem. The following is a typical scenario: </p>
  
  <ol>
  <li>Log-in and load the main page. </li>
  <li>Click Link-A : This opens Page-A in a pop-up window. </li>
  <li>Click Link-A 50 times: This opens Page-A 50 times reusing the same pop-up window. </li>
  <li>Refresh the DataTable in the main window using AJAX: <strong>this will throw</strong> a <code>PageExpiredException</code>. </li>
  </ol>
  
  <p>All this can happen in just one minute after logging in (new session), meaning the session is still valid. </p>
  
  <p>We don’t know exactly what the problem is, but we managed to ‘delay’ getting this exception by increasing the value of <code>maxSizePerPageSession</code> in the <code>DefaultPageManagerProvider</code>. Looking at Wicket's source code, in the end this value is used by the <code>DataStore</code> / <code>PageWindowManager</code>. </p>
  
  <p>We don’t think this is the best solution and we would like to understand what the problem is so we can address it in a better way. </p>
  
  <p>We are using Wicket 1.5-RC2. </p>
  
  <p>This is the stack trace: </p>
  
  <blockquote>
    <p>org.apache.wicket.protocol.http.PageExpiredException: Page expired. 
                    at org.apache.wicket.request.handler.PageProvider.getPageInstance(PageProvider.java:164) 
                    at org.apache.wicket.request.handler.ListenerInterfaceRequestHandler.getPage(ListenerInterfaceRequestHandler.java:89) 
                    at org.apache.wicket.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:141) 
                    at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:706) 
                    at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:63) 
                    at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:212) 
                    at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:253) 
                    at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:138) 
                    at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:194) 
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244) 
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
                    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240) 
                    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) 
                    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) 
                    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) 
                    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541) 
                    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) 
                    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:383) 
                    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:284) 
                    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:322) 
                    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1684) 
                    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) 
                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
                    at java.lang.Thread.run(Unknown Source) </p>
  </blockquote>