You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alfonso Quiroga <al...@gmail.com> on 2012/11/15 19:30:46 UTC

CouldNotLockPageException in production

Hi! We have a simple wicket application, which does NOT save page versions,
because we do this:

Application#getPageSettings().setVersionPagesByDefault(false);

The application is in production running in a Jboss, and sometimes we have
this exception:

org.apache.wicket.page.CouldNotLockPageException: Could not lock page 0.
Attempt lasted 1 minute
at
org.apache.wicket.page.PageAccessSynchronizer.lockPage(PageAccessSynchronizer.java:146)
at
org.apache.wicket.page.PageAccessSynchronizer$2.getPage(PageAccessSynchronizer.java:197)
at
org.apache.wicket.DefaultMapperContext.getPageInstance(DefaultMapperContext.java:117)

Any ideas? We are using Wicket 1.5.8

Re: CouldNotLockPageException in production

Posted by Alfonso Quiroga <al...@gmail.com>.
Martin, thank you, I could resolve this problem yesterday, I share the
solution because it helps somebody

We have a backend, and in some custom searches it can take 50 or 60 seconds
(or more) to get the results.
When the backend is searching, and the user press "BACK BUTTON", we've a
strategy that tries to get the SAME page (same instance) and in this point
is where the exception raises. This is is because we don't use page
versioning, so the home page has always the page-id "1".  So:

* when the page is blocked searching, and more than 1 minute has happened
(default time), if the user press BACK BUTTON and wicket tries to recover
the same page-instance, the exception CouldNotLockPageException is rised

* if we have the same scenario but the user press BACK BUTTON before 1
minute, nothing happens (works fine)

So we've done 2 solutions

First, change the default request timeout to 5 minutes, doing this:

Application#getRequestCycleSettings().setTimeout(  Duration.minutes(5)  );
   (because we know that our backend can take all that time)

Then, in my exception-handler, if "CouldNotLockPageException" is rised, I
capture it, and then I invalidate the session and I force redirection to
login page.

If someone needs the code of the exception handler  (method onExcetion() )

(..)
boolean couldNotLock = anException.getCause() != null
        &&
anException.getCause().getClass().equals(InvocationTargetException.class)
        && anException.getCause().getCause() != null
        &&
anException.getCause().getCause().getClass().equals(CouldNotLockPageException.class);

if (couldNotLock) {
   - invalidate session
   - redirect to login page
}

(...)

thanks


On Fri, Nov 16, 2012 at 5:30 AM, Martin Grigorov <mg...@apache.org>wrote:

> Hi,
>
> Look again in the logs. Next to this exception there is another one
> explaining which thread keeps a reference to the page for more than one
> minute.
>
> References:
> org.apache.wicket.settings.IExceptionSettings#setThreadDumpStrategy
> org.apache.wicket.settings.IRequestCycleSettings#getTimeout
>
> On Thu, Nov 15, 2012 at 8:30 PM, Alfonso Quiroga <alfonsosebaq@gmail.com
> >wrote:
>
> > Hi! We have a simple wicket application, which does NOT save page
> versions,
> > because we do this:
> >
> > Application#getPageSettings().setVersionPagesByDefault(false);
> >
> > The application is in production running in a Jboss, and sometimes we
> have
> > this exception:
> >
> > org.apache.wicket.page.CouldNotLockPageException: Could not lock page 0.
> > Attempt lasted 1 minute
> > at
> >
> >
> org.apache.wicket.page.PageAccessSynchronizer.lockPage(PageAccessSynchronizer.java:146)
> > at
> >
> >
> org.apache.wicket.page.PageAccessSynchronizer$2.getPage(PageAccessSynchronizer.java:197)
> > at
> >
> >
> org.apache.wicket.DefaultMapperContext.getPageInstance(DefaultMapperContext.java:117)
> >
> > Any ideas? We are using Wicket 1.5.8
> >
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com <http://jweekend.com/>
>

Re: CouldNotLockPageException in production

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Look again in the logs. Next to this exception there is another one
explaining which thread keeps a reference to the page for more than one
minute.

References:
org.apache.wicket.settings.IExceptionSettings#setThreadDumpStrategy
org.apache.wicket.settings.IRequestCycleSettings#getTimeout

On Thu, Nov 15, 2012 at 8:30 PM, Alfonso Quiroga <al...@gmail.com>wrote:

> Hi! We have a simple wicket application, which does NOT save page versions,
> because we do this:
>
> Application#getPageSettings().setVersionPagesByDefault(false);
>
> The application is in production running in a Jboss, and sometimes we have
> this exception:
>
> org.apache.wicket.page.CouldNotLockPageException: Could not lock page 0.
> Attempt lasted 1 minute
> at
>
> org.apache.wicket.page.PageAccessSynchronizer.lockPage(PageAccessSynchronizer.java:146)
> at
>
> org.apache.wicket.page.PageAccessSynchronizer$2.getPage(PageAccessSynchronizer.java:197)
> at
>
> org.apache.wicket.DefaultMapperContext.getPageInstance(DefaultMapperContext.java:117)
>
> Any ideas? We are using Wicket 1.5.8
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>