[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
[Home]
ClassCastException -- From dup class load???
ClassCastException -- From dup class load???
I am having a problem with a utility class (MyUser) which I am storing
in the HttpSession collection. As long as a JSP stays loaded, access is
fine. When I edit the page, and it recompiles, I get a
ClassCastException when trying to pull an instance of MyUser saved
previously (in: session.)
I confirmed that I was trying to properly cast the object by confirming
it's name via getClass().getName(). The names match, but the object
won't cast.
While it's only a startup issue for access from the same page (if it
fails, it just creates a new one -- it's the login page) when I try to
access the MyUser object from another page, the MyUser object won't
cast, even though it gives the same name there too.
My guess is that the MyUser class is loaded for each of the pages, and
the tests for class cast compatibility are based on its in memory
pointer chains. The Cast test doesn't see the identity between the two
instances of the class because they are at different memory locations,
in different chains.
The MyUser class is an independent class kept in the common GNUJSP
servlet zone.
I saw notes in the archive about extending from a common class as a work
around, which I'll try tomorrow. However one of the prior notes seemed
to indicate that this sort of thing worked fine in some of the .9
versions, without using the 'extends' approach.
Is there a design or spec reason why this functionality went away? Is
there something else I should be doing to prevent a second loading of
the desired class?
Any thoughts?
Harrison
I am running RH 6.0, Apache 1.3.9, Jserv 1.0, Blackdown 1.1.7, and
GNUJSP 1.3b? from earlier this month/end of Sept..