users@glassfish.java.net

Re: Classloader Load Order

From: Sahoo <sanjeeb.sahoo_at_oracle.com>
Date: Tue, 10 Apr 2012 21:00:28 +0530

If you want predictable classpath for your jars in WEB-INF/lib/*.jar,
then just have one empty jar with Class-Path manifest set to something like:

WEB-INF/lib/all-my-jars.jar has following manifest:
     Class-Path: myjars/a.jar myjars/b.jar

a.jar and b.jar are in WEB-INF/lib/myjars/

If this does not solve your issue, provide more information like:
Where is this Class-Path defined? What's the structure of your war?
e.g., send jar tf <your war> | grep "*.jar"

Sahoo
On Tuesday 10 April 2012 02:30 PM, forums_at_java.net wrote:
> Hi I have one question regarding the load order of the Classloader inf
> Glassfis 3.1.x. f.e. I have a war file with a manifest.mf file In the
> manifest.mf file I have declared two jar Files inside the war file: f.e.
> Class-Path: lib/b.jar lib/a.jar It seems that the order of this
> entries is
> simply ignored, at least with java x64. in b.jar I have classes which
> should
> overwrite classes from a.jar, because they are project specific different
> from the product class files in a.jar. This means they are classes
> with the
> same name ... How can I tell Glassfish to load classes with same name
> from
> b.jar first than from a.jar? It seems that Glassfish is loading the
> jars in
> an alphabetical order, instead of the order declined in the
> manifest.mf File.
> But this looks to be a game of luck... Thank you for your help
>
> --
>
> [Message sent by forum member 'christoph.bernhofer']
>
> View Post: http://forums.java.net/node/884980
>
>