{"record":{"id":"8f7e35d47fe2ed70","repo":"quarkusio/quarkus","slug":"no-vertx-context-found-8f7e35","errorCode":null,"errorMessage":"No Vertx context found","messagePattern":"No Vertx context found","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-reactive/rest-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/PrepareExecution.kt","lineNumber":14,"sourceCode":"package org.jboss.resteasy.reactive.server.runtime.kotlin\n\nimport io.vertx.core.Vertx\nimport jakarta.enterprise.inject.spi.CDI\nimport kotlinx.coroutines.CoroutineDispatcher\nimport org.jboss.resteasy.reactive.server.core.ResteasyReactiveRequestContext\n\nfun prepareExecution(\n    requestContext: ResteasyReactiveRequestContext\n): Pair<CoroutineDispatcher, ApplicationCoroutineScope> {\n    val requestScope = requestContext.captureCDIRequestScope()\n    val dispatcher: CoroutineDispatcher =\n        Vertx.currentContext()?.let { VertxDispatcher(it, requestScope, requestContext) }\n            ?: throw IllegalStateException(\"No Vertx context found\")\n\n    val coroutineScope = CDI.current().select(ApplicationCoroutineScope::class.java)\n    requestContext.suspend()\n\n    return Pair(dispatcher, coroutineScope.get())\n}\n","sourceCodeStart":1,"sourceCodeEnd":21,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-reactive/rest-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/PrepareExecution.kt#L1-L21","documentation":"prepareExecution is a shared helper that builds the coroutine dispatcher and application scope for Kotlin suspend/Flow endpoints. It captures the CDI request scope and requires an active Vert.x context; otherwise it throws IllegalStateException(\"No Vertx context found\").","triggerScenarios":"suspend or Flow endpoint execution invoked on a thread lacking a Vert.x context, so `Vertx.currentContext()` returns null while building the VertxDispatcher.","commonSituations":"Direct invocation of suspend endpoints outside the HTTP pipeline; custom executor/threading setups; corrupted dispatch chain where request handling left the Vert.x context.","solutions":["Route requests through the normal RESTEasy Reactive HTTP pipeline","Avoid moving request handling to non-Vert.x threads before coroutine preparation","In tests, use the QuarkusTest HTTP client instead of direct method calls","Check extensions that alter threading/dispatch (e.g. custom @RunOnVirtualThread setups)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"require(io.vertx.core.Vertx.currentContext() != null) { \"prepareExecution requires an active Vert.x context\" }","typeGuard":"fun prepareExecutionSafe(ctx: ResteasyReactiveRequestContext): Pair<CoroutineDispatcher, ApplicationCoroutineScope>? =\n    if (io.vertx.core.Vertx.currentContext() != null) prepareExecution(ctx) else null","tryCatchPattern":"try {\n    val (dispatcher, scope) = prepareExecution(requestContext)\n    // proceed\n} catch (e: IllegalStateException) {\n    if (e.message?.contains(\"No Vertx context found\") == true) {\n        requestContext.handleException(e, true)\n    } else throw e\n}","preventionTips":["Route all coroutine endpoint requests through Vert.x-managed threads","Avoid executor pools that detach the Vert.x context","Audit extensions that re-thread request handling"],"tags":["kotlin","coroutines","vertx","threading","resteasy-reactive"],"backgroundTag":"missing-vertx-context","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}