Undertow: Servlet context path failing with `_static` directory
### Describe the bug

Running PrimeFaces Integration Tests with 999-SNAPSHOT nightly gets this..

```
An error occured while initializing MyFaces: 
Unable to get listed resource _static from directory  for path  from underlying manager io.undertow.server.handlers.resource.ClassPathResourceManager@35c3d6e8
```

Caused by fix for: https://github.com/quarkusio/quarkus/issues/28028

### Expected behavior

No error to occur

### Actual behavior

```
An error occured while initializing MyFaces: 
Unable to get listed resource _static from directory  for path  from underlying manager io.undertow.server.handlers.resource.ClassPathResourceManager@35c3d6e8
```

### How to Reproduce?

See PrimeFaces Extension nightly integration Test: https://github.com/quarkiverse/quarkus-primefaces/actions/runs/4728799924/jobs/8390684815

### Output of `uname -a` or `ver`

_No response_

### Output of `java -version`

OpenJDK Runtime Environment Temurin-17.0.6+10 (build 17.0.6+10)

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

999-SNAPSHOT

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

Apache Maven 3.9.1 (2e178502fcdbffc201671fb2537d0cb4b4cc58f8)

### Additional information

_No response_
diff --git a/extensions/undertow/spi/src/main/java/io/quarkus/undertow/deployment/UndertowStaticResourcesBuildStep.java b/extensions/undertow/spi/src/main/java/io/quarkus/undertow/deployment/UndertowStaticResourcesBuildStep.java
index f0db4f8b070..5846c627da3 100644
--- a/extensions/undertow/spi/src/main/java/io/quarkus/undertow/deployment/UndertowStaticResourcesBuildStep.java
+++ b/extensions/undertow/spi/src/main/java/io/quarkus/undertow/deployment/UndertowStaticResourcesBuildStep.java
@@ -12,6 +12,8 @@
 import java.util.List;
 import java.util.Set;
 
+import io.quarkus.bootstrap.classloading.ClassPathElement;
+import io.quarkus.bootstrap.classloading.QuarkusClassLoader;
 import io.quarkus.deployment.ApplicationArchive;
 import io.quarkus.deployment.Capabilities;
 import io.quarkus.deployment.Capability;
@@ -22,7 +24,6 @@
 import io.quarkus.deployment.builditem.LaunchModeBuildItem;
 import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
 import io.quarkus.runtime.LaunchMode;
-import io.quarkus.runtime.util.ClassPathUtils;
 
 /**
  * NOTE: Shared with Resteasy standalone!
@@ -56,8 +57,8 @@ void scanStaticResources(Capabilities capabilities, ApplicationArchivesBuildItem
         }
         //we need to check for web resources in order to get welcome files to work
         //this kinda sucks
-        Set<String> knownFiles = new HashSet<>();
-        Set<String> knownDirectories = new HashSet<>();
+        final Set<String> knownFiles = new HashSet<>();
+        final Set<String> knownDirectories = new HashSet<>();
         for (ApplicationArchive i : applicationArchivesBuildItem.getAllApplicationArchives()) {
             i.accept(tree -> {
                 Path resource = tree.getPath(META_INF_RESOURCES);
@@ -67,9 +68,14 @@ void scanStaticResources(Capabilities capabilities, ApplicationArchivesBuildItem
             });
         }
 
-        ClassPathUtils.consumeAsPaths(META_INF_RESOURCES, resource -> {
-            collectKnownPaths(resource, knownFiles, knownDirectories);
-        });
+        for (ClassPathElement e : QuarkusClassLoader.getElements(META_INF_RESOURCES, false)) {
+            if (e.isRuntime()) {
+                e.apply(tree -> {
+                    collectKnownPaths(tree.getPath(META_INF_RESOURCES), knownFiles, knownDirectories);
+                    return null;
+                });
+            }
+        }
 
         for (GeneratedWebResourceBuildItem genResource : generatedWebResources) {
             String sub = genResource.getName();
diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java
index 440a8d6f5f2..8b653f334f3 100644
--- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java
+++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java
@@ -39,19 +39,19 @@ public class QuarkusClassLoader extends ClassLoader implements Closeable {
         registerAsParallelCapable();
     }
 
-    public static List<ClassPathElement> getElements(String resourceName, boolean localOnly) {
+    public static List<ClassPathElement> getElements(String resourceName, boolean onlyFromCurrentClassLoader) {
         final ClassLoader ccl = Thread.currentThread().getContextClassLoader();
         if (!(ccl instanceof QuarkusClassLoader)) {
             throw new IllegalStateException("The current classloader is not an instance of "
                     + QuarkusClassLoader.class.getName() + " but " + ccl.getClass().getName());
         }
-        return ((QuarkusClassLoader) ccl).getElementsWithResource(resourceName, localOnly);
+        return ((QuarkusClassLoader) ccl).getElementsWithResource(resourceName, onlyFromCurrentClassLoader);
     }
 
-    public List<ClassPathElement> getAllElements(boolean localOnly) {
+    public List<ClassPathElement> getAllElements(boolean onlyFromCurrentClassLoader) {
         List<ClassPathElement> ret = new ArrayList<>();
-        if (parent instanceof QuarkusClassLoader && !localOnly) {
-            ret.addAll(((QuarkusClassLoader) parent).getAllElements(localOnly));
+        if (parent instanceof QuarkusClassLoader && !onlyFromCurrentClassLoader) {
+            ret.addAll(((QuarkusClassLoader) parent).getAllElements(onlyFromCurrentClassLoader));
         }
         ret.addAll(elements);
         return ret;
['independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java', 'extensions/undertow/spi/src/main/java/io/quarkus/undertow/deployment/UndertowStaticResourcesBuildStep.java']