tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hui Linn <>
Subject Re: java.lang.ClassCastException
Date Thu, 07 Dec 2000 09:43:15 GMT

> Date: Thu, 07 Dec 2000 08:20:47 +0000
> To:
> From: "Jon Skeet" <>
> Subject: Re: java.lang.ClassCastException
> Message-ID: <>
> > This an intermitten problem that crops up once in a while.
> > A java object SearchResult is put into the Session object
> > by servlet1 and taken out by servlet2 which type cast it back
> > to (SearchResult), if it's not null.
> > 
> > Ocassionally, servlet2 will throw java.lang.ClassCastException.
> > However, the object retrieved is not null and it IS the
> > correct casting.
> Is it perhaps due to a new classloader being used? Does this happen when
> the servlet is recompiled half way through the operation?
> Jon

No, the servlet it not compiled in the server. It's compiled on my PC 
and uploaded. However, thanks for the tip. I can reproduce the error 
consistently now.

It happens whenever my colleague or I uploaded servlet1 or servlet2 and 
the servlet reloads. I have stop/start tomcat to get rid of the exception.
Presumably it forces tomcat to reload all the classes, not just the servlet 
in question.

Funny thing is, the changes to servlet1/2 is trivial 
	(e.g. add another statement "System.err.println();")
and not related to the type casting/usage of the SearchResult class/object.
Even the SearchResult class/object remains the same.
Is this what you mean by new classloader being used?

Well, at least I know what to look out for. 
Spent half a day wondering what went wrong with the servlets ...

Thanks again.


View raw message