AFAIK we don't do any special handling of the extra classpath. The order of paths that are added to the URLClassLoader that is the webapp classloader is:
* extra classpath * WEB-INF/classes * WEB-INF/lib/*.jar The webapp classloader getResource(String) method first looks in itself before looking in the parent (to conform to servlet spec inverted classloading requirements), however the looking is all delegated to the URLClassLoader, so it is whatever ordering the jvm has implemented, which according to GrepCode http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/sun/misc/URLClassPath.java#URLClassPath.0urls looks like the search order will be as above. cheers Jan On 21 April 2017 at 13:48, Matthew Sheppard <[email protected]> wrote: > TL;DR: Is it expected that resources in .jar files included > via WebAppContext’s setExtraClasspath method would be loaded in > preference to resources with the same name/path within the .war? > > —— > > I’m in the process of moving some dependencies out of .war files and > including them instead via WebAppContext’s setExtraClasspath method ( > http://www.eclipse.org/jetty/documentation/current/jetty- > classloading.html#using-extra-classpath-method) > > While doing so, I ran into a problem where one of the .jar files now moved > out contains an ehcache.xml file, which seems to be read in preference to > the one within the .war when `Thread.currentThread(). > getContextClassLoader().getResourceAsStream(“ehcache.xml”)` is used. > > Now that I know that to be the case, I guess it’s not a big inconvenience > to me if I need to rename the file to be unique, but I guess I’m wondering… > > - Am I loading the resource incorrectly (and if so, how can I do it to the > .war takes priority)? > > - Was it only luck that the .war version took precedence previously (when > the .jar in question was packed within the .war)? > > - Is this an expected drawback of using setExtraClasspath that I just have > to live with? > > - Did I miss some documentation somewhere which would have clarified this > for me? > > > Many thanks for any pointers, > Matt > > _______________________________________________ > jetty-users mailing list > [email protected] > To change your delivery options, retrieve your password, or unsubscribe > from this list, visit > https://dev.eclipse.org/mailman/listinfo/jetty-users > -- Jan Bartel <[email protected]> www.webtide.com *Expert assistance from the creators of Jetty and CometD*
_______________________________________________ jetty-users mailing list [email protected] To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users
