You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Michael Chandler <Mi...@onassignment.com> on 2013/06/27 18:30:20 UTC

Unusual Serialization issue

I'm getting a serialization error when I shutdown Tomcat that has me confused.

java.io.NotSerializableException: com.oa.frontoffice.service.AuthenticationService

I experienced quite a bit of this at first before learning that Wicket serializes quite heavily, but gained a more thorough understanding of models and wrap my business objects in a LoadableDetachableModel like this:

private boolean authenticate() {
                LoadableDetachableModel<AuthenticationService> service = new LoadableDetachableModel<AuthenticationService>() {

                                private static final long serialVersionUID = 1L;

                                @Override
                                protected AuthenticationService load() {
                                                return new AuthenticationService();
                                }

                };

                authMessage = service.getObject().authenticate(username, password);

                if (authMessage != "SUCCESS") {
                                return false;
                }

                return true;
}

Nevertheless, invoking my custom authenticate() method above seems to trigger this serialization exception upon shut down and I'm unsure as to why that is.  The AuthenticationService class itself makes no references to any other classes so I don't know the root cause of this issue.  If anyone has any advice on where I might need to look, I would greatly appreciate the assistance.

Mike Chandler


Re: Unusual Serialization issue

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

Usually when there is a problem with serialization Wicket prints a
descriptive message which *field* is problematic.
Your code above could not be the problem because Java serializes only
object instances and their member fields. Your code above shows only method
local variables which are stored in the thread stack memory and never
serialized.


On Thu, Jun 27, 2013 at 7:30 PM, Michael Chandler <
Michael.Chandler@onassignment.com> wrote:

> I'm getting a serialization error when I shutdown Tomcat that has me
> confused.
>
> java.io.NotSerializableException:
> com.oa.frontoffice.service.AuthenticationService
>
> I experienced quite a bit of this at first before learning that Wicket
> serializes quite heavily, but gained a more thorough understanding of
> models and wrap my business objects in a LoadableDetachableModel like this:
>
> private boolean authenticate() {
>                 LoadableDetachableModel<AuthenticationService> service =
> new LoadableDetachableModel<AuthenticationService>() {
>
>                                 private static final long serialVersionUID
> = 1L;
>
>                                 @Override
>                                 protected AuthenticationService load() {
>                                                 return new
> AuthenticationService();
>                                 }
>
>                 };
>
>                 authMessage = service.getObject().authenticate(username,
> password);
>
>                 if (authMessage != "SUCCESS") {
>                                 return false;
>                 }
>
>                 return true;
> }
>
> Nevertheless, invoking my custom authenticate() method above seems to
> trigger this serialization exception upon shut down and I'm unsure as to
> why that is.  The AuthenticationService class itself makes no references to
> any other classes so I don't know the root cause of this issue.  If anyone
> has any advice on where I might need to look, I would greatly appreciate
> the assistance.
>
> Mike Chandler
>
>