diff --git a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/MetaInfConfiguration.java b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/MetaInfConfiguration.java index 770d8676bcd..7118acab72b 100644 --- a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/MetaInfConfiguration.java +++ b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/MetaInfConfiguration.java @@ -148,7 +148,13 @@ public class MetaInfConfiguration extends AbstractConfiguration Consumer addContainerResource = (uri) -> { Resource resource = _resourceFactory.newResource(uri); - context.getMetaData().addContainerResource(resource); + if (resource == null || !resource.exists()) + { + if (LOG.isDebugEnabled()) + LOG.debug("Classpath URI doesn't exist: " + uri); + } + else + context.getMetaData().addContainerResource(resource); }; List containerUris = getAllContainerJars(context); @@ -379,6 +385,10 @@ public class MetaInfConfiguration extends AbstractConfiguration */ public void scanForResources(WebAppContext context, Resource target, ConcurrentHashMap cache) { + // Resource target does not exist + if (target == null || !target.exists()) + return; + Resource resourcesDir = null; if (cache != null && cache.containsKey(target)) { @@ -691,12 +701,19 @@ public class MetaInfConfiguration extends AbstractConfiguration if (webInf == null || !webInf.exists() || !webInf.isDirectory()) return List.of(); - Resource webInfLib = webInf.resolve("/lib"); + Resource webInfLib = webInf.resolve("lib"); - return webInfLib.list().stream() - .filter((lib) -> FileID.isLibArchive(lib.getFileName())) - .sorted(ResourceCollators.byName(true)) - .collect(Collectors.toList()); + if (webInfLib != null && webInfLib.exists() && webInfLib.isDirectory()) + { + return webInfLib.list().stream() + .filter((lib) -> FileID.isLibArchive(lib.getFileName())) + .sorted(ResourceCollators.byName(true)) + .collect(Collectors.toList()); + } + else + { + return List.of(); + } } /** @@ -733,14 +750,13 @@ public class MetaInfConfiguration extends AbstractConfiguration return null; Resource webInf = context.getWebInf(); - // Find WEB-INF/classes if (webInf != null && webInf.isDirectory()) { // Look for classes directory - Resource classes = webInf.resolve("classes/"); - if (classes.exists()) - return classes; + Resource webInfClassesDir = webInf.resolve("classes/"); + if (webInfClassesDir != null && webInfClassesDir.exists() && webInfClassesDir.isDirectory()) + return webInfClassesDir; } return null; }