The standardmanager persist sessions across reload using serialization.
That mean all object in session must be serializable.
An object is serializable if
1) it implements the Serializable interface (see also the externalizable
interface which give more control on serialization)
2) it has an no-parameter constructor
3) all it's instance fields are serializable

The serialization process does not store or restore static field,
because those are class wide and not related to object instance.

En l'instant précis du 07/05/07 09:20, mélanie langlois s'exprimait en
ces termes:
> Hello,
>
> We are running tomcat 5.0.28, and we have a problem with the
> standardManager when restarting our application. We have a
> NullPointerException when the StandardManager loads a session
> object.This object has static fields calling another class method (to
> obtain the bundles key for some page title). However, this second
> class has not been iniatlized yet,
Ok, you have class A static initialization assume some class B static
methods calls were before (maybe during a servlet initialization , a
context listerner or filter job), this is a big design problem, you can
not easily be sure of when class A will be static initialized by
classloader. This is weak design as it's very difficult to be 100% sure
of class initialization order in a code.
> and I can see that the standard Manager initialize this class after.
> But it's too late, the NullPointerException makes it impossible to
> access the index page properly. We need to restart.
Standard Manager does not initialize classes, it initialize instances of
those classes. It's the classloader that does the job of static
initialization of classes.
> How does the standard manager works ? Does it try to load all static
> objects first ?
persistence is done only on object instances, the classloader does
static initialization of class members, standardManager does
unserialization, all  unserialization does is a Object o =
someClass.newInstance(); and then put unserialized values in 'o' fields.
> Why the startup is working fine when the standard manager is not
> launched (no session persisted )?
Because order in which your classloader statically initialize your
classes is not the same if you don't try at startup to unserialize user
session.

Possible solutions:
1) revise design of your session objects, those should be serializable
to be in session. Move the static field to another object shared by all
users.
2) Don't put this problematic object in the session.
3) Don't use session persistence (aka don't use a Manager)
>
> Thanks,
>
> Mélanie
>
> _________________________________________________________________
> Gagnez des pc Windows Vista avec Live.com http://www.image-addict.fr/
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to