Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6877507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:36:31+00:00 2026-05-27T04:36:31+00:00

I’m working on a large Java application that uses Wicket 1.5 together with Hibernate

  • 0

I’m working on a large Java application that uses Wicket 1.5 together with Hibernate / JPA 2. Wicket has a standard rule that objects stored in the session must implement Serializable. We have an extra rule that JPA managed objects must not be stored in the session. Instead, JPA managed objects are loaded on each request through detachable models.

To complicate matters, it is legitimate to store an Entity object in the session provided that it has not been persisted yet. As a result, some of our classes already implement Serializable.

If I wanted to extend Wicket’s serialization test to detect objects owned by JPA, how would I go about it? Is this possible without a local fork of Wicket?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:36:31+00:00Added an answer on May 27, 2026 at 4:36 am

    At my $dayjob we use something what you describe, and what I have presented at several meetups (see slide 23 and on). You don’t have to fork Wicket for that.

    Basically what you do is copy the serializer checker code and modify it to include your check as well as checking for serialization errors. Then in the last phase of the request cycle you run your own serializer checker on the affected pages.

    The check we created checks for our common base class, and wether or not the entity has ben persisted. If so, we fail the request. Additionally we have an Ajax callback in our base page that checks a session attribute to see if there was a serialization error. If so, we redirect to the error page with the serialization failure, to ensure that developers don’t ignore the entity in page hierarchy.

    Here’s the meat of our checker (the check method rewritten from Wicket’s serializer check):

    private void check(Object obj)
    {
        if (obj == null || obj.getClass().isAnnotationPresent(Deprecated.class)
            || obj.getClass().isAnnotationPresent(SkipClass.class))
        {
            return;
        }
    
        Class< ? > cls = obj.getClass();
        nameStack.add(simpleName);
        traceStack.add(new TraceSlot(obj, fieldDescription));
    
        if (!(obj instanceof Serializable) && (!Proxy.isProxyClass(cls)))
        {
            throw new WicketNotSerializableException(toPrettyPrintedStack(obj.getClass().getName())
                .toString(), exception);
        }
        if (obj instanceof IdObject)
        {
            Serializable id = ((IdObject) obj).getIdAsSerializable();
            if (id != null && !(id instanceof Long && ((Long) id) <= 0))
            {
                throw new WicketContainsEntityException(toPrettyPrintedStack(
                    obj.getClass().getName()).toString(), exception);
            }
        }
        if (obj instanceof LoadableDetachableModel)
        {
            LoadableDetachableModel< ? > ldm = (LoadableDetachableModel< ? >) obj;
            if (ldm.isAttached())
            {
                throw new WicketContainsAttachedLDMException(toPrettyPrintedStack(
                    obj.getClass().getName()).toString(), exception);
            }
        }
    

    For Wicket 1.5 we created our own PageStoreManager that performs these checks (and a lot of other things, like enabling a server side browsing history for our users). We provided our own RequestAdapter by overriding PageStoreManager#newRequestAdapter(IPageManagerContext context) and doing the serialization check in the adapter:

    class DetachCheckingRequestAdapter extends RequestAdapter
    {
        public DetachCheckingRequestAdapter(IPageManagerContext context)
        {
            super(context);
        }
    
        @Override
        protected void storeTouchedPages(List<IManageablePage> touchedPages)
        {
            super.storeTouchedPages(touchedPages);
            if (Application.get().usesDevelopmentConfig())
            {
                for (IManageablePage curPage : touchedPages)
                {
                    if (!((Page) curPage).isErrorPage())
                        testDetachedObjects(curPage);
                }
            }
        }
    
        private void testDetachedObjects(final IManageablePage page)
        {
            try
            {
                NotSerializableException exception = new NotSerializableException();
                EntityAndSerializableChecker checker = new EntityAndSerializableChecker(exception);
                checker.writeObject(page);
            }
            catch (Exception ex)
            {
                log.error("Couldn't test/serialize the Page: " + page + ", error: " + ex);
                Session.get().setDetachException(ex);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a French site that I want to parse, but am running into
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.