Apache wicket – page store – error while using AsynchronousPageStore

Apache wicket – page store – error while using AsynchronousPageStore

Problem Description:

I am trying to use AsynchronousPageStore for our Application, by doing the following

First I created an asynchronous DiskPageStore

public class McAsynchronousDiskPageStore extends DiskPageStore
    {

        public McAsynchronousDiskPageStore()
        {
            super( PortalApp.this.getName(), PortalApp.this.getStoreSettings().getFileStoreFolder(), Bytes.kilobytes( 40000));
        }

        @Override
        public boolean canBeAsynchronous(IPageContext context)
        {
            return true;
        }

    }

To pass it as delegate for an implementation of AsynchronousPageStore

public class CustomPageStoreManeger extends AsynchronousPageStore
{

    private final IPageStore delegate;

    public CustomPageStoreManeger(IPageStore delegate)
    {
        super( delegate, 100);
        this.delegate = delegate;
    }

    @Override
    public void destroy()
    {

        Logger.getLogger( this).logInfo( " page store Size" + ((IPersistentPageStore)delegate).getTotalSize());

    }

    @Override
    public void addPage(IPageContext context, IManageablePage page)
    {
        if( INotPersistentPage.class.isAssignableFrom( page.getClass()))
        {
            Logger.getLogger( this).debug( " ignoring page persitence" + page.getClass());
        }
        else
        {
            super.addPage( context, page);
        }
    }

I’m setting it as follows in my WicketApplication class

    setPageManagerProvider( new DefaultPageManagerProvider( this)

    {

        @Override
        protected IPageStore newPersistentStore()

        {

            return new CustomPageStoreManeger( new McAsynchronousDiskPageStore());

        }

    });

yet , I get the following error in the console

09:31:44,699 ERROR [AsynchronousPageStore$PageAddingRunnable] (Wicket-AsyncPageStor) An error occurred while saving asynchronously 'PendingAdd [sessionId=6A4jzJpJbU8YMgb9J-_npsnLGsywu6xi0jJmkAiY, pageId=7, pageClass=org.apache.wicket.pageStore.SerializedPage]': org.apache.wicket.WicketRuntimeException: session attribute can not be changed asynchronuously
    at deployment.xx-12.0.ear//org.apache.wicket.pageStore.AsynchronousPageStore$PendingAdd.getSessionAttribute(AsynchronousPageStore.java:198)
    at deployment.xx-12.0.ear//org.apache.wicket.pageStore.AsynchronousPageStore$PendingAdd.getSessionAttribute(AsynchronousPageStore.java:201)
    at deployment.xx-12.0.ear//org.apache.wicket.pageStore.AbstractPersistentPageStore.getSessionIdentifier(AbstractPersistentPageStore.java:149)
    at deployment.xx-12.0.ear//org.apache.wicket.pageStore.AbstractPersistentPageStore.canBeAsynchronous(AbstractPersistentPageStore.java:76)
    at deployment.xx-12.0.ear//org.apache.wicket.pageStore.AsynchronousPageStore.addPage(AsynchronousPageStore.java:369)
    at deployment.xx-12.0.ear.web.war/xxx.PortalApp$CustomPageStoreManeger.addPage(PortalApp.java:206)
    at deployment.xx-12.0.ear//org.apache.wicket.pageStore.AsynchronousPageStore$PageAddingRunnable.run(AsynchronousPageStore.java:292

any idea what I might be doing wrong here?

Solution – 1

IMO there is no need of McAsynchronousDiskPageStore.

Instead of overriding #newPersistentStore() in DefaultPageManagerProvider you should override protected IPageStore newAsynchronousStore(IPageStore pageStore) and return McAsynchronousDiskPageStore without any delegates.

https://github.com/apache/wicket/blob/0c4b88e16a3ec7478fbc8f86991c6b07805ed821/wicket-core/src/main/java/org/apache/wicket/DefaultPageManagerProvider.java#L158

Rate this post
We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.
Accept
Reject