[EMAIL PROTECTED] wrote:
>
> On Sat, 15 Sep 2001, Bojan Smojver wrote:
>
> > - if the jar file is changed, the application will reload (due to some
> > recent fixes there in DependClassLoader), but some resources might not
> > get loaded properly (for instance a properties file from within that
> > jar)
>
> What do you mean ( i.e. how do you load the properties ) ? We create a new
> loader, and getting resources with the new loader should return the new
> stuff ( I'm not sure for Bundles, maybe they're caching something - need
> to check ).
I'm loading the properties files (which can be any other type of file,
really) by calling getResourceAsStream() on the classloader of my
servlet. First time ever, all three of the properties files get pulled
in OK. I verified that by printing out the properties and passing them
to Velocity. Next time around (after the jar file gets updates), two
things can happen: properties files don't get pulled in correctly or the
class itself doesn't get pulled in correctly and I get
ClassNotFoundException (ie. app doesn't run at all).
> > - if old version of the jar file, or a new jar file with the same binary
> > of the class is returned back to WEB-INF/lib, sometimes the app will
> > come back to normal after an automatic reload (not always though)
>
> > - if you keep replacing jar file long enough with different versions, it
> > will eventually fail even when loading class files from it and the whole
> > app will stop working (ClassNotFoundException)
>
> Again, need more details.
>
> > I've checked the code in DependClassLoader and (unfortunately) it calls
> > the parent's equivalent methods for getResourceAsStream() and
> > getResource(), where parent is java.net.FactoryURLClassLoader. parent2
> > is the same as class as parent, but different object (ie. another
> > instance of the same thing). I'm guessing those things are part of the
> > JDK.
>
> DependClassLoader is a wrapper around the real webapp loader - it's role
> is to record dependencies.
>
> Parent is the real loader, parent2 is the grand-parent ( the parent of
> all webapps ). If a resource can be loaded by parent2, it is loaded
> ( to respect the delegation rules ). If not, we get the resource from
> parent ( i.e. from the application WEB-INF ).
>
> The class is created by DependClassLoader so class deps will also go
> to DCL ( and we can record them ).
>
> URLClassLoader is the standard JDK1.2+ loader. It has some important
> features besides loading classes - it checks sealing, load the right
> security context, and many other things that are imporant.
>
> You can of course replace it with anything you want - including
> SimpleClassLoader or replacement. All you need to do is replace
> LoaderInterceptor with your custom-made one.
Aha, so that's what I need to change (not that I'm going to do it for
real - no security - just wanted to test). Thanks!
> > So, my real question here is, do any of you Sun guys (or any of you with
> > better knowledge of JDK) know what this java.net.FactoryURLClassLoader
> > actually does? Is it kind of 'caching' stuff and then it gets seriously
> > confused when there are changes? Or maybe I'm doing something I'm not
> > supposed to do...
>
> If you can provide more details, I can take a look. Reloading seems to
> work fine for me ( but I'll try again ).
Even from jars stored in WEB-INF/lib? I found that part to behave in a
really erratic manner. When I have plain classes in WEB-INF/classes,
everything seems to behave much, much better.
bojan