Did you try casting it directly, like:

User user=(User)getSession().get(Constantes.USER_SESSION_KEY);

?

If not, try logging (or debug to it) the class name of the object you've
got:

getSession().getAttribute("aa").getClass().getCanonicalName() (or getName())

Loggers and debuggers are great for this...



meissa.sakho-2 wrote:
> 
> 
> I'm troubleshooted with this starnge behaviour of the session.
> I have implemented SessionAware and have defined a session attribute of 
> Map type with getter (and setter)
> as indicated to handle session.
> 
> I'm putting a User objet to the session and want to retrieve it after some 
> steps.
> The code below gives me an Object that is already well typed.
> 
> Object user=getSession().get(Constantes.USER_SESSION_KEY);
> 
> 
> I'm seeing the object  but when I try to Cast it, like that
> 
> user=(User)user;
> 
>  I'm getting a ClasscastException.
> 
> What am I missing here ?
> why can't we cast objects from the session.
> 
> Meissa
> 
> 
> L'integrite de ce message n'etant pas assuree sur internet, Natixis ne
> peut etre tenu responsable de son contenu. Toute utilisation ou diffusion
> non autorisee est interdite. Si vous n'etes pas destinataire de ce
> message, merci de le detruire et d'avertir l'expediteur.
> Ensemble, faisons un geste pour l'environnement : n'imprimons nos mails
> que si necessaire
> 
> The integrity of this message cannot be guaranteed on the Internet.
> Natixis can not therefore be considered responsible for the contents. Any
> unauthorized use or dissemination is prohibited. If you are not the
> intended recipient of this message, then please delete it and notify the
> sender.
> Let us mind the environment : let's print our mails only when necessary.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/can%27t-cast-an-object-back-from-session-tf4481550.html#a12779996
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to