https://issues.apache.org/bugzilla/show_bug.cgi?id=57172
Bug ID: 57172 Summary: NullPointerException in findResources of WebappClassLoader Product: Tomcat 8 Version: 8.0.14 Hardware: PC Status: NEW Severity: normal Priority: P2 Component: Catalina Assignee: dev@tomcat.apache.org Reporter: jhuxh...@googlemail.com Enumeration<URL> findResources(String name) of class org.apache.catalina.loader.WebappClassLoaderBase (for Tomcat 8.0.14, the code was located in org.apache.catalina.loader.WebappClassLoader for Tomcat 8.0.12) throws a NullPointerException if the "resources" attribute is null. I'm unsure why it is null in some cases (restarting the server, instead of simply redeploying one of our apps, fixes the issue for us) but this should be fixed in the classloader implementation anyway. The code looks like this WebResource[] webResources = resources.getClassLoaderResources(path); for (WebResource webResource : webResources) { if (webResource.exists()) { result.add(webResource.getURL()); } } and should be replaced by if (resources != null) { WebResource[] webResources = resources.getClassLoaderResources(path); for (WebResource webResource : webResources) { if (webResource.exists()) { result.add(webResource.getURL()); } } } Searching for this problem returns results as old as 2006. Other code that's using "resources" without null check: public boolean modified() public void start() protected ResourceEntry findResourceInternal(final String name, final String path) Code that already acknowledges that "resources" may be null: public String getContextName() { if (resources == null) { return "Unknown"; } else { return resources.getContext().getName(); } } Full stacktrace of our specific issue (running on Tomcat 8.0.12): java.lang.NullPointerException at org.apache.catalina.loader.WebappClassLoader.findResources(WebappClassLoader.java:998) at java.lang.ClassLoader.getResources(ClassLoader.java:1139) at java.util.ServiceLoader$LazyIterator.hasNextService(ServiceLoader.java:348) at java.util.ServiceLoader$LazyIterator.hasNext(ServiceLoader.java:393) at java.util.ServiceLoader$1.hasNext(ServiceLoader.java:474) at javax.xml.stream.FactoryFinder$1.run(FactoryFinder.java:352) at java.security.AccessController.doPrivileged(Native Method) at javax.xml.stream.FactoryFinder.findServiceProvider(FactoryFinder.java:341) at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:313) at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:227) at javax.xml.stream.XMLInputFactory.newFactory(XMLInputFactory.java:205) The XMLInputFactory.newFactory() is executed in initialValue() of a ThreadLocal<XMLInputFactory>. -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org