users@glassfish.java.net

Re: Custom Web-app Loader - How To?

From: Sivakumar Thyagarajan <Sivakumar.Thyagarajan_at_Sun.COM>
Date: Thu, 25 Oct 2007 10:17:43 +0530

Hi

>> interim. On the other hand, if this puts my web
>> app's docroot in a higher classloader then this is a
>> non-starter as the classes loaded from my docroot
>> depend on classes in WEB-INF/lib/*.jar and thus
>> these must all be in the same classloader -- and I
>> don't want to have to change the config every time
>> something else gets added to WEB-INF/lib.

Yes, placing a jar in the classpath-prefix places it in a classloader way above
in the hierarchy [to be specific, it prefixed the "shared chain" classloader.

For more gory details, please refer
https://glassfish.dev.java.net/javaee5/docs/DG/beade.html#beadf] and yes, as you
have rightly pointed out, if the docroot jars have references to
WEB-INF/lib/*.jars this would not work.

So if I understand correctly, you want to place some jars in docroot [that
depends on some jars in WEB-INF/lib], placed before WEB-INF/lib and hence should
be placed in the same classloader. Why do you want to control the order of jars
in a particular classloader? Do you expect jars placed in docroot to "shadow"
jars in WEB-INF/lib [ie. having two versions of a library in docroot and
web-inf/lib and expecting the docroot version to win?]?

If my understanding of your usecase above is right, "libraries" [application
specific classloader] also would not help us, because the specified "libraries"
for a web-app, are loaded by a classloader above the web-app, and hence
"docroot" jars would not have access to "web-inf/lib" jars.

The hierarchy for libraries would be something like this:

[connector classloader] - (1)
|
[libraries specified for web app "foo"] - (2)
|
[web app classloader "foo"] - (3)

The docroot jars would be loaded in (2) and will not be able to resolve
references to web-inf/lib classes in (3).

For this specific usecase, I don't think the current classloading options would
help. You might want to consider subclassing Tomcat discussions you were having
in this thread with JeanFrancois as the only option for now.

Thanks
--Siva



glassfish_at_javadesktop.org wrote:
>> First off I'd rather not modify the classloading of
>> all deployed applications -- I am trying to avoid
>> that.
>>
>> Secondly what would modifying classpath-prefix do?
>> Would it put each web app's docroot at the front of
>> *its* loader? If so, that's of interest in the
>> interim. On the other hand, if this puts my web
>> app's docroot in a higher classloader then this is a
>> non-starter as the classes loaded from my docroot
>> depend on classes in WEB-INF/lib/*.jar and thus
>> these must all be in the same classloader -- and I
>> don't want to have to change the config every time
>> something else gets added to WEB-INF/lib.
>
> OK, then this hack is not for you.
> classpath-prefix modifies the effective classloading of the entire server.
> [Message sent by forum member 'km' (km)]
>
> http://forums.java.net/jive/thread.jspa?messageID=242003
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>