Well actually, the answer is in your question.

When you store data in the session, it is stored on the server. When you
update the .class file, your server automatically restarts cause you have
the autoreload on.
So the server stops and restarts, and when it does, it destroys your
session, thus loosing all data stored in it ! Then when you ask for stuff in
the session (session.getAttribute("someStuff") ), it sends back a null
object.
This is all very normal, I've had the same thing happen to me.

Try checking to see if the Usuario object is null when you pull it out of
the HttpSession. If it is, instantiate it. If you need data gotten from user
input to instantiate it, send the user back to the first page.

Hope it helped.



----- Original Message -----
From: "João Robertson Kramer Santana" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 01, 2001 5:41 PM
Subject: ClassCastException


>         We are using Tomcat 3.2.1 and it is configured with "autoreload"
> because in an developement environment we are always making changes to the
> source code and don´t want to stop/start the Web Server every time a new
or
> upgraded servlet is ready to be tested. This has been be the ideal
> developemnt environment for us until we started to have problems wit a
> ClassCastException.
>         The problem is that we are using the HttpSession to store
> information about the logged user in a class named "Usuario". There is a
> starting servlet that is resposible for creating the user class
("Usuario")
> and storing it in the HttpSession. The other classes access the
HttpSession
> , retreive the user object and make a cast to the class named Ususario.
This
> works fine until the moment we need to upgrade a class with a new version.
> This time, when the "upgraded class" retreives the user object from the
> HttpSession and tries to make a cast an ClassCastException occurs. This
> error does not occur with the other classes that were not upgraded.
>         Are we forgetting something important about the how the servlets
> work ? Is this a limitation or problem in the Tomcat 3.2.1 implemntation ?
> Can someone bring us some ligth on what is going on.
>
>         Thanks in advance for the help.
>
>         bye
>                 jk
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to