You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by mélanie langlois <me...@hotmail.fr> on 2007/05/07 09:20:35 UTC

nullpointerexception with standard manager

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, 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.
How does the standard manager works ? Does it try to load all static objects 
first ?
Why the startup is working fine when the standard manager is not launched 
(no session persisted )?

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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: nullpointerexception with standard manager

Posted by Rashmi Rubdi <ra...@gmail.com>.
On 5/9/07, mélanie langlois <me...@hotmail.fr> wrote:
>
> Hi,
> Thank you for your explanation.
>
> Actually, we don't need this feature in our application, so i want to
> disable the persistence of session.

To disable the persistence of session add this

<Manager className="org.apache.catalina.session.PersistentManager"
saveOnRestart="false"/>

between the opening and closing <Context> tag

>However, we are running tomcat 5.0.28
> and for several reasons, we don't want to upgrade for now. Is it possible to
> disable this in 5.0.28 ?

It may be possible, but I can't say for sure because I haven't tested
it on 5.0.28 - doesn't hurt to test it.


 I saw only explanation for doing this on tomcat
> 5.5.x by modifying context.xml ..
>
> Thanks,
>
> Mélanie
>

-Rashmi

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


Re: nullpointerexception with standard manager

Posted by mélanie langlois <me...@hotmail.fr>.
Hi,
Thank you for your explanation.

Actually, we don't need this feature in our application, so i want to 
disable the persistence of session. However, we are running tomcat 5.0.28 
and for several reasons, we don't want to upgrade for now. Is it possible to 
disable this in 5.0.28 ? I saw only explanation for doing this on tomcat 
5.5.x by modifying context.xml ..

Thanks,

Mélanie

>From: David Delbecq <de...@oma.be>
>Reply-To: "Tomcat Users List" <us...@tomcat.apache.org>
>To: Tomcat Users List <us...@tomcat.apache.org>
>Subject: Re: nullpointerexception with standard manager
>Date: Mon, 07 May 2007 10:36:27 +0200
>
>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: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
>
>
>---------------------------------------------------------------------
>To start a new topic, e-mail: users@tomcat.apache.org
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>

_________________________________________________________________
Personnalisez votre Messenger avec Live.com 
http://www.windowslive.fr/livecom/


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


Re: nullpointerexception with standard manager

Posted by David Delbecq <de...@oma.be>.
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: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


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