Repository: quarkusio/quarkus
Issue: IllegalArgumentException: workerPoolSize must be > 0 if quarkus:dev fails to start

While developing an extension, if any error is thrown during initialization, the following misleading exception appears in the logs when running quarkus:dev: 

```
15:27:48,255 ERROR [io.qua.dev.DevModeMain] Failed to start quarkus: java.lang.IllegalArgumentException: workerPoolSize must be > 0
	at io.vertx.core.VertxOptions.setWorkerPoolSize(VertxOptions.java:275)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder.convertToVertxOptions(VertxCoreRecorder.java:151)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder.initializeWeb(VertxCoreRecorder.java:104)
	at io.quarkus.vertx.http.runtime.VertxHttpRecorder.startServerAfterFailedStart(VertxHttpRecorder.java:115)
	at io.quarkus.vertx.http.deployment.devmode.VertxHotReplacementSetup.handleFailedInitialStart(VertxHotReplacementSetup.java:30)
	at io.quarkus.dev.RuntimeUpdatesProcessor.startupFailed(RuntimeUpdatesProcessor.java:451)
	at io.quarkus.dev.DevModeMain.doStart(DevModeMain.java:192)
	at io.quarkus.dev.DevModeMain.start(DevModeMain.java:96)
	at io.quarkus.dev.DevModeMain.main(DevModeMain.java:67)
```

Changed files:
extensions/vertx/runtime/src/main/java/io/quarkus/vertx/runtime/VertxProducer.java
extensions/vertx/runtime/src/test/java/io/quarkus/vertx/runtime/VertxProducerTest.java
core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedDevModeMain.java

diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedDevModeMain.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedDevModeMain.java
index 0ae4c4b402c..065a221ab96 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedDevModeMain.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedDevModeMain.java
@@ -41,7 +41,7 @@
 
 public class IsolatedDevModeMain implements BiConsumer<CuratedApplication, Map<String, Object>>, Closeable {
 
-    private static final Logger log = Logger.getLogger(DevModeMain.class);
+    private static final Logger log = Logger.getLogger(IsolatedDevModeMain.class);
     public static final String APP_ROOT = "app-root";
 
     private volatile DevModeContext context;
@@ -101,7 +101,6 @@ public void accept(Integer integer) {
                 } else {
                     //we need to set this here, while we still have the correct TCCL
                     //this is so the config is still valid, and we can read HTTP config from application.properties
-                    log.error("Failed to start Quarkus", t);
                     log.info("Attempting to start hot replacement endpoint to recover from previous Quarkus startup failure");
                     if (runtimeUpdatesProcessor != null) {
                         Thread.currentThread().setContextClassLoader(curatedApplication.getBaseRuntimeClassLoader());
@@ -142,6 +141,8 @@ public synchronized void restartApp(Set<String> changedResources) {
             } catch (Throwable t) {
                 deploymentProblem = t;
                 log.error("Failed to start quarkus", t);
+                Thread.currentThread().setContextClassLoader(curatedApplication.getAugmentClassLoader());
+                LoggingSetupRecorder.handleFailedStart();
             }
         } finally {
             restarting = false;
diff --git a/extensions/vertx/runtime/src/main/java/io/quarkus/vertx/runtime/VertxProducer.java b/extensions/vertx/runtime/src/main/java/io/quarkus/vertx/runtime/VertxProducer.java
index fcd77bbf196..a5640bda6da 100644
--- a/extensions/vertx/runtime/src/main/java/io/quarkus/vertx/runtime/VertxProducer.java
+++ b/extensions/vertx/runtime/src/main/java/io/quarkus/vertx/runtime/VertxProducer.java
@@ -10,7 +10,6 @@
 import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
-import javax.inject.Inject;
 import javax.inject.Singleton;
 
 import org.jboss.logging.Logger;
@@ -34,25 +33,22 @@ public class VertxProducer {
 
     private static final Logger LOGGER = Logger.getLogger(VertxProducer.class);
 
-    @Inject
-    Vertx vertx;
-
     @Singleton
     @Produces
-    public EventBus eventbus() {
+    public EventBus eventbus(Vertx vertx) {
         return vertx.eventBus();
     }
 
     @Singleton
     @Produces
-    public io.vertx.mutiny.core.Vertx mutiny() {
+    public io.vertx.mutiny.core.Vertx mutiny(Vertx vertx) {
         return io.vertx.mutiny.core.Vertx.newInstance(vertx);
     }
 
     @Singleton
     @Produces
     @Deprecated
-    public io.vertx.axle.core.Vertx axle() {
+    public io.vertx.axle.core.Vertx axle(Vertx vertx) {
         LOGGER.warn(
                 "`io.vertx.axle.core.Vertx` is deprecated and will be removed in a future version - it is "
                         + "recommended to switch to `io.vertx.mutiny.core.Vertx`");
@@ -62,7 +58,7 @@ public io.vertx.axle.core.Vertx axle() {
     @Singleton
     @Produces
     @Deprecated
-    public io.vertx.reactivex.core.Vertx rx() {
+    public io.vertx.reactivex.core.Vertx rx(Vertx vertx) {
         LOGGER.warn(
                 "`io.vertx.reactivex.core.Vertx` is deprecated  and will be removed in a future version - it is "
                         + "recommended to switch to `io.vertx.mutiny.core.Vertx`");
@@ -102,8 +98,7 @@ public io.vertx.mutiny.core.eventbus.EventBus mutinyEventBus(io.vertx.mutiny.cor
      * @param event
      * @param beanManager
      */
-    void undeployVerticles(@Observes @BeforeDestroyed(ApplicationScoped.class) Object event,
-            BeanManager beanManager, io.vertx.mutiny.core.Vertx mutiny) {
+    void undeployVerticles(@Observes @BeforeDestroyed(ApplicationScoped.class) Object event, BeanManager beanManager) {
         // Only beans with the AbstractVerticle in the set of bean types are considered - we need a deployment id 
         Set<Bean<?>> beans = beanManager.getBeans(AbstractVerticle.class, Any.Literal.INSTANCE);
         Context applicationContext = beanManager.getContext(ApplicationScoped.class);
@@ -115,6 +110,8 @@ void undeployVerticles(@Observes @BeforeDestroyed(ApplicationScoped.class) Objec
                     // Only existing instances are considered
                     try {
                         AbstractVerticle verticle = (AbstractVerticle) instance;
+                        io.vertx.mutiny.core.Vertx mutiny = beanManager.createInstance()
+                                .select(io.vertx.mutiny.core.Vertx.class).get();
                         mutiny.undeploy(verticle.deploymentID()).await().indefinitely();
                         LOGGER.debugf("Undeployed verticle: %s", instance.getClass());
                     } catch (Exception e) {
diff --git a/extensions/vertx/runtime/src/test/java/io/quarkus/vertx/runtime/VertxProducerTest.java b/extensions/vertx/runtime/src/test/java/io/quarkus/vertx/runtime/VertxProducerTest.java
index 725df6cfc9c..1868eb04ee4 100644
--- a/extensions/vertx/runtime/src/test/java/io/quarkus/vertx/runtime/VertxProducerTest.java
+++ b/extensions/vertx/runtime/src/test/java/io/quarkus/vertx/runtime/VertxProducerTest.java
@@ -8,6 +8,7 @@
 import org.junit.jupiter.api.Test;
 
 import io.quarkus.vertx.core.runtime.VertxCoreRecorder;
+import io.vertx.core.Vertx;
 
 public class VertxProducerTest {
 
@@ -27,24 +28,23 @@ public void tearDown() {
 
     @Test
     public void shouldNotFailWithoutConfig() {
-        producer.vertx = VertxCoreRecorder.initialize(null, null);
-        verifyProducer();
+        verifyProducer(VertxCoreRecorder.initialize(null, null));
     }
 
-    private void verifyProducer() {
-        assertThat(producer.eventbus()).isNotNull();
+    private void verifyProducer(Vertx v) {
+        assertThat(producer.eventbus(v)).isNotNull();
 
-        assertThat(producer.axle()).isNotNull();
-        assertFalse(producer.axle().isClustered());
-        assertThat(producer.axleEventBus(producer.axle())).isNotNull();
+        assertThat(producer.axle(v)).isNotNull();
+        assertFalse(producer.axle(v).isClustered());
+        assertThat(producer.axleEventBus(producer.axle(v))).isNotNull();
 
-        assertThat(producer.rx()).isNotNull();
-        assertFalse(producer.rx().isClustered());
-        assertThat(producer.rxEventBus(producer.rx())).isNotNull();
+        assertThat(producer.rx(v)).isNotNull();
+        assertFalse(producer.rx(v).isClustered());
+        assertThat(producer.rxEventBus(producer.rx(v))).isNotNull();
 
-        assertThat(producer.mutiny()).isNotNull();
-        assertFalse(producer.mutiny().isClustered());
-        assertThat(producer.mutinyEventBus(producer.mutiny())).isNotNull();
+        assertThat(producer.mutiny(v)).isNotNull();
+        assertFalse(producer.mutiny(v).isClustered());
+        assertThat(producer.mutinyEventBus(producer.mutiny(v))).isNotNull();
 
     }
 }