Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Resource loading priority when setExtraClasspath is used

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 (

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,

Back to the top