tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jiger Java" <>
Subject RE: having to restart tomcat for new classes -More
Date Sat, 12 Jan 2002 05:52:53 GMT
Hi Craig,
>* Creating objects based on classes loaded from /WEB-INF/classes or
>   /WEB-INF/lib, but passing references to them to classes that are
>   loaded from the shared class loader (and are thus NOT reloaded by
>   the reloading mechanism).  The old objects survive the reload (because
>   there are still live references to them, so they cannot be
>   garbage collected).  But they are GUARANTEED to cause a
>   ClassCastException when you try to reference them after the reload
>   completes.
   I my case I am NOT loading anything from shared classpath. nor am I 
giving references to them of classes in /WEB-INF/classes or /WEB-INF/lib 
classes. So this is very funny & annoying error.
  If u had read my previous mails, I had described that I was using a 
Utility that I created on the samelines as Struts BeanUtil.populateBean() 
method. Which auto-populates FormBean's from request or Hastables.
    It works perfectly well normally, but as soon as I recompile any class 
in my webapp triggering webapp reload, The formbean population fails for 
some methods, so my validate will return false & the app goes into loop 
showing errors highlighted although user has filled in all the required 
   If I still continue, tomcat starts giving me annoying errors like 
ClassCastException, NoClassDefFound, LinkageError and what not.
   I could send u my stacktraces once more if u want.This seems to be a bug 
of how all classes loaded from the same place, then destroyed & Re-created 
start giving problems.

Any idea.

Thanks & Awaiting your reply,
> > Can u just explain how can we prevent classloading errors & points to 
> > in mind so that even if entire Context is being restarted does not 
> > our app.
> >
>The simplest rule is to put 100% -- that's every single one -- of your
>application classes, plus any library classes that your application uses,
>under /WEB-INF/classes or /WEB-INF/lib, instead of in a shared library
>directory.  That way, they will always get reloaded when your webapp does.
>If you use shared JAR files (for example, from Tomcat's "lib" directory),
>you need to absolutely ensure that there are no references to the old
>objects (loaded from /WEB-INF) kept by objects that are loaded by a shared
>class loader.  As you can imagine, this is a much harder thing to do.  The
>suggestion in the previous paragraph is much simpler to implement, and
>avoids pretty much all potential problems.
> > Thanks & Awaiting your reply,
> > Jiger
> >
>To unsubscribe:   <>
>For additional commands: <>
>Troubles with the list: <>

MSN Photos is the easiest way to share and print your photos:

To unsubscribe:   <>
For additional commands: <>
Troubles with the list: <>

View raw message