Thanks for the candid reply Chuck. I feel a bit stupid now, but one learns from their mistakes.
With kind regards, Mike On 22 April 2011 23:19, Caldarale, Charles R <chuck.caldar...@unisys.com>wrote: > > From: Michael Anstis [mailto:michael.ans...@gmail.com] > > Subject: Tomcat 6: Classloading: META-INF\services: Nested JARs > > > ClassLoader.getSystemResources("META-INF/services/AFile) > > We'll assume that the missing closing quotation mark is a typo. > > > However the file is not found. > > Nor should it be; let's read the API spec: > > getSystemResources > > public static Enumeration<URL> getSystemResources(String name) > throws IOException > > Finds all resources of the specified name from the search path used to > load classes. The resources thus found are returned as an Enumeration of URL > objects. > > The search order is described in the documentation for > getSystemResource(String). > > getSystemResource > > public static URL getSystemResource(String name) > > Find a resource of the specified name from the search path used to load > classes. This method locates the resource through the system class loader > (see getSystemClassLoader()). > > Note that the getSystemResources() method is *static*, so it's unrelated to > the your webapp's classloader. This is further clarified by the doc for > getSystemResource(), which explicitly says it uses only the system class > loader (hence the use of the word "system" in the method names). > > > Am I doing something stupid? Should this work? > > Yes. No. > > You need to use an instance method of your webapp's classloader; > getResourceAsStream() is usually recommended, since that keeps the operation > independent of the file system (even in cases where there isn't one, such as > inside a JAR). Thread.currentThread().getContextClassLoader() is a way to > get a reference to your current classloader, assuming you're running inside > a servlet. > > - Chuck > > > THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY > MATERIAL and is thus for use only by the intended recipient. If you received > this in error, please contact the sender and delete the e-mail and its > attachments from all computers. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > >