tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jon Skeet" <jon.sk...@peramon.com>
Subject Re: java.lang.ClassCastException
Date Thu, 07 Dec 2000 10:37:35 GMT
> > Is it perhaps due to a new classloader being used? Does this happen when
> > the servlet is recompiled half way through the operation?

> 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.

Yes, I essentially meant "has the servlet changed".
 
> 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?

A new classloader will be used to load the new servlet. That classloader
will be used within that servlet, and two different classloaders' versions
of the same class count as different classes in the JVM. Thus the object
in the session has the old classloader, whereas the thing trying to use
it is using the new classloader.

Just starting a new session each time you upload your servlet should cure
the problem.

Jon

Mime
View raw message