You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Kevin Jones <ke...@develop.com> on 2000/03/03 16:46:14 UTC

Reloading screws beans in sessions

I have a servlet running.
In that servlet I store an object in the HttpSession
I rebuild the servlet and it gets reloaded.
When I try and access the object previously stored in the session I get a
'ClassCastException'

My guess is that the reloaded servlet is associated with a different class
loader than the original servlet. The original class loader creates the
bean, and it gets stored in the session. When I reload the servlet, it tries
to access that bean, but we now have a different class loader, so logically
a different type, hence the class cast exception!

Kevin Jones
www.develop.com