Repository: quarkusio/quarkus
Issue: Broken access in openapi and swagger-ui extensions

**Describe the bug**
Openapi and swagger-ui intergrations are broken. https://github.com/quarkusio/quarkus-quickstarts/tree/master/using-openapi-swaggerui is also broken. It starts up, but /openapi endpoint and /swagger-ui respond with errors.

**Expected behavior**
Cool openapi and swagger pages, heh

**Symptoms**
Adding config key resolves problem in production env, but dev still errors.
```
quarkus.swagger-ui.always-include=true
```
Also it's strange that when I'm not adding this line, openapi is still available in production - not sure how safe is this.

**Openapi error info**
```
Context Path:
Servlet Path: /openapi
Path Info: null
Query String: null

Stack Trace:
java.io.FileNotFoundException: /quarkus-generated-openapi-doc.YAML
	at io.undertow.servlet.handlers.DefaultServlet.doGet(DefaultServlet.java:173)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:686)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:791)
	at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
	at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:81)
	at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
	at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
	at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:274)
	at io.undertow.servlet.handlers.ServletInitialHandler.dispatchToServlet(ServletInitialHandler.java:219)
	at io.undertow.servlet.spec.RequestDispatcherImpl.includeImpl(RequestDispatcherImpl.java:392)
	at io.undertow.servlet.spec.RequestDispatcherImpl.setupIncludeImpl(RequestDispatcherImpl.java:327)
	at io.undertow.servlet.spec.RequestDispatcherImpl.include(RequestDispatcherImpl.java:291)
	at io.quarkus.smallrye.openapi.runtime.OpenApiServlet.doGet(OpenApiServlet.java:65)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:686)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:791)
	at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
	at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
	at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
	at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
	at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
	at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
	at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
	at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
	at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
	at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:91)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
	at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
	at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
	at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
	at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
	at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
	at io.quarkus.undertow.runtime.UndertowDeploymentTemplate$7$1$1.call(UndertowDeploymentTemplate.java:469)
	at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
	at io.undertow.servlet.handlers.ServletInitialHandler.handleRequest(ServletInitialHandler.java:197)
	at io.undertow.server.handlers.HttpContinueReadHandler.handleRequest(HttpContinueReadHandler.java:65)
	at io.quarkus.undertow.runtime.UndertowDeploymentTemplate$1.handleRequest(UndertowDeploymentTemplate.java:104)
	at io.undertow.server.handlers.CanonicalPathHandler.handleRequest(CanonicalPathHandler.java:49)
	at io.quarkus.undertow.deployment.devmode.UndertowHotReplacementSetup.handleHotDeploymentRequest(UndertowHotReplacementSetup.java:77)
	at io.quarkus.undertow.deployment.devmode.UndertowHotReplacementSetup$1$1.handleRequest(UndertowHotReplacementSetup.java:56)
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:364)
	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
	at io.quarkus.runtime.CleanableExecutor$CleaningRunnable.run(CleanableExecutor.java:236)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1538)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1429)
	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:32)
	at java.lang.Thread.run(Thread.java:748)
	at org.jboss.threads.JBossThread.run(JBossThread.java:479)
```

**To Reproduce**
Steps to reproduce the behavior:
1. clone https://github.com/quarkusio/quarkus-quickstarts
2. cd /using-openapi-swaggerui/
3. ./mvnw compile quarkus:dev
4. http://localhost:8080/openapi - BANG
5. http://localhost:8080/swagger-ui - TWO TIME BANG :)

**Environment**
 - OpenSUSE Tumbleweed, kernel  5.1.3-1
 - JVM Version: Zulu 8.36.0.1
 - Quarkus 0.16.0: 

**Linked issue in this repo**
https://github.com/quarkusio/quarkus/issues/2597
**Linked issue in this quarkus-quickstarts repo**
https://github.com/quarkusio/quarkus-quickstarts/issues/207
**Probable cause**
https://github.com/quarkusio/quarkus/commit/4dcb8131f8018a46ddf098bd5c14beb4aa230404 - this commit added ability to enable swagger-ui in production env, and there was a lot of code, so some bug ought to be there.

Changed files:
extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/UndertowStaticResourcesBuildStep.java
devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java

diff --git a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
index f78d8f5456a..dabdd16d6f0 100644
--- a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
+++ b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
@@ -280,8 +280,12 @@ public void execute() throws MojoFailureException, MojoExecutionException {
             }
 
             args.add("-Djava.util.logging.manager=org.jboss.logmanager.LogManager");
+            //wiring devmode is used for CDI beans that are not part of the user application (i.e. beans in 3rd party jars)
+            //we need this because these beans cannot be loaded by the runtime class loader, they must be loaded by the platform
+            //class loader
             File wiringClassesDirectory = new File(buildDir, "wiring-devmode");
             wiringClassesDirectory.mkdirs();
+
             addToClassPaths(classPathManifest, devModeContext, wiringClassesDirectory);
 
             //we also want to add the maven plugin jar to the class path
diff --git a/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/UndertowStaticResourcesBuildStep.java b/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/UndertowStaticResourcesBuildStep.java
index 92f22bd654f..bdc6a79c615 100644
--- a/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/UndertowStaticResourcesBuildStep.java
+++ b/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/UndertowStaticResourcesBuildStep.java
@@ -26,6 +26,15 @@ public class UndertowStaticResourcesBuildStep {
     protected static final String META_INF_RESOURCES_SLASH = "META-INF/resources/";
     protected static final String META_INF_RESOURCES = "META-INF/resources";
 
+    @BuildStep
+    void handleGeneratedWebResources(BuildProducer<GeneratedResourceBuildItem> generatedResources,
+            List<GeneratedWebResourceBuildItem> generatedWebResources) throws Exception {
+        for (GeneratedWebResourceBuildItem genResource : generatedWebResources) {
+            generatedResources.produce(new GeneratedResourceBuildItem(META_INF_RESOURCES_SLASH + genResource.getName(),
+                    genResource.getClassData()));
+        }
+    }
+
     @BuildStep
     KnownPathsBuildItem scanStaticResources(ApplicationArchivesBuildItem applicationArchivesBuildItem,
             BuildProducer<GeneratedResourceBuildItem> generatedResources,
@@ -83,8 +92,6 @@ public void accept(Path path) {
             }
         }
         for (GeneratedWebResourceBuildItem genResource : generatedWebResources) {
-            generatedResources.produce(new GeneratedResourceBuildItem(META_INF_RESOURCES_SLASH + genResource.getName(),
-                    genResource.getClassData()));
             String sub = genResource.getName();
             if (sub.startsWith("/")) {
                 sub = sub.substring(1);