diff --git a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppClassLoader.java b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppClassLoader.java index 60e5c99af3e..23c022c3115 100644 --- a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppClassLoader.java +++ b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppClassLoader.java @@ -223,38 +223,20 @@ public class WebAppClassLoader extends URLClassLoader implements ClassVisibility } /** - * @param resource Comma or semicolon separated path of filenames or URLs - * pointing to directories or jar files. Directories should end - * with '/'. + * @param resources The resources to add to the classpath * @throws IOException if unable to add classpath from resource */ - public void addClassPath(Resource resource) + public void addClassPath(Resource resources) throws IOException { - if (resource instanceof ResourceCollection) + for (Resource resource: resources) { - for (Resource r : ((ResourceCollection)resource).getResources()) - { - addClassPath(r); - } - } - else - { - // Resolve file path if possible - Path path = resource.getPath(); - if (path != null) - { - URL url = resource.getURI().toURL(); - addURL(url); - } - else if (resource.isDirectory()) - { + if (resource != null && resource.exists()) addURL(resource.getURI().toURL()); - } else { if (LOG.isDebugEnabled()) - LOG.debug("Check file exists and is not nested jar: {}", resource); + LOG.debug("Check resource exists and is not a nested jar: {}", resource); throw new IllegalArgumentException("File not resolvable or incompatible with URLClassloader: " + resource); } } @@ -273,11 +255,7 @@ public class WebAppClassLoader extends URLClassLoader implements ClassVisibility return; List uris = URIUtil.split(classPath); - ResourceCollection rc = _resourceFactory.newResource(uris); - for (Resource resource : rc.getResources()) - { - addClassPath(resource); - } + addClassPath(_resourceFactory.newResource(uris)); } /** @@ -298,13 +276,16 @@ public class WebAppClassLoader extends URLClassLoader implements ClassVisibility * Add elements to the class path for the context from the jar and zip files found * in the specified resource. * - * @param lib the resource that contains the jar and/or zip files. + * @param libs the directory resource that contains the jar and/or zip files. */ - public void addJars(Resource lib) + public void addJars(Resource libs) { - if (lib.exists() && lib.isDirectory()) + if (libs == null || !libs.exists() || !libs.isDirectory()) + return; + + for (Resource libDir: libs) { - Path dir = lib.getPath(); + Path dir = libDir.getPath(); try (Stream streamEntries = Files.list(dir)) { @@ -314,7 +295,7 @@ public class WebAppClassLoader extends URLClassLoader implements ClassVisibility .sorted(Comparator.naturalOrder()) .toList(); - for (Path jar: jars) + for (Path jar : jars) { try {