{"record":{"id":"515fd9504cebdb89","repo":"quarkusio/quarkus","slug":"no-current-vertx-context-found-515fd9","errorCode":null,"errorMessage":"No current Vertx context found","messagePattern":"No current Vertx context found","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/Panache.java","lineNumber":113,"sourceCode":"            current.close();\n        } finally {\n            MongodbPanacheContextLocalsProvider.SESSION_LOCAL.remove(context);\n        }\n    }\n\n    /**\n     *\n     * @return the current vertx duplicated context\n     * @throws IllegalStateException If no vertx context is found or is not a safe context as mandated by the\n     *         {@link VertxContextSafetyToggle}\n     */\n    private static Context vertxContext() {\n        Context context = Vertx.currentContext();\n        if (context != null) {\n            VertxContextSafetyToggle.validateContextIfExists(ERROR_MSG, ERROR_MSG);\n            return context;\n        } else {\n            throw new IllegalStateException(\"No current Vertx context found\");\n        }\n    }\n}\n","sourceCodeStart":95,"sourceCodeEnd":117,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/Panache.java#L95-L117","documentation":"Reactive Panache operations rely on the current Vert.x context to resolve context objects. Panache.vertxContext() throws IllegalStateException when Vertx.currentContext() returns null, i.e. the code is executing outside any Vert.x context.","triggerScenarios":"Calling reactive Panache helpers (e.g. Panache.withSession/withTransaction) from a thread that is not a Vert.x worker/event-loop thread, such as a plain executor thread or a blocking main thread.","commonSituations":"Calling reactive APIs from @Blocking methods or scheduled executors; using reactive Panache in tests without a Vert.x context; mixing blocking code with reactive Panache static helpers.","solutions":["Invoke reactive Panache code only within Vert.x-managed contexts (RESTEasy Reactive endpoints, Vert.x routes, Quarkus-managed Uni subscriptions)","Wrap the work in Quarkus-managed reactive execution instead of a custom executor","Switch to the imperative/blocking Panache API if you must run on a plain thread"],"exampleFix":"// before (plain thread)\nexecutor.submit(() -> Panache.withSession(() -> entity.persist()));\n// after (Quarkus-managed reactive)\nPanache.withSession(() -> entity.persist()).await().indefinitely();","handlingStrategy":"try-catch","validationCode":"if (io.vertx.core.Vertx.currentContext() == null) {\n    throw new IllegalStateException(\"Reactive Panache requires a Vert.x context\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    return Panache.withSession(() -> repo.persist(e)).await().indefinitely();\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"No current Vertx context\")) throw new IllegalStateException(\"Call reactive Panache from a Vert.x context\", e);\n    throw e;\n}","preventionTips":["Never call reactive Panache from @Blocking methods or custom executors","Use RESTEasy Reactive endpoints or Vert.x-managed threads","Prefer the blocking Panache API on plain threads"],"tags":["quarkus","mongodb-panache","vertx","reactive","context"],"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-12T22:17:10.623Z"}