{"record":{"id":"63f7dfab538ae958","repo":"quarkusio/quarkus","slug":"mongo-client-s-is-not-active","errorCode":null,"errorMessage":"Mongo Client '%s' is not active","messagePattern":"Mongo Client '(.+?)' is not active","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/MongoClients.java","lineNumber":145,"sourceCode":"            //force class init to prevent possible deadlock when done by mongo threads\n            Class.forName(\"sun.net.ext.ExtendedSocketOptions\", true, ClassLoader.getSystemClassLoader());\n        } catch (ClassNotFoundException ignored) {\n        }\n    }\n\n    /**\n     * Creates an unmanaged {@link MongoClient} using the configuration for a specific client name. Callers must close\n     * the client manually.\n     * <p>\n     * Intended for use by Mongo DB schema management tools.\n     *\n     * @param clientName the MongoDB client name.\n     * @return a {@link MongoClient}\n     */\n    public MongoClient unmanagedMongoClient(String clientName) throws MongoException {\n        MongoClientConfig clientConfig = mongoConfig.clients().get(clientName);\n        if (!clientConfig.active()) {\n            throw new IllegalStateException(String.format(\"Mongo Client '%s' is not active\", clientName));\n        }\n        MongoClientSettings mongoConfiguration = createMongoConfiguration(clientConfig, clientName, false);\n        return com.mongodb.client.MongoClients.create(mongoConfiguration, DRIVER_INFORMATION);\n    }\n\n    MongoClient createMongoClient(String clientName) throws MongoException {\n        MongoClientConfig clientConfig = mongoConfig.clients().get(clientName);\n        if (!clientConfig.active()) {\n            throw new IllegalStateException(String.format(\"Mongo Client '%s' is not active\", clientName));\n        }\n        return mongoClients.computeIfAbsent(clientName, new Function<String, MongoClient>() {\n            @Override\n            public MongoClient apply(String s) {\n                MongoClientSettings mongoConfiguration = createMongoConfiguration(clientConfig, clientName, false);\n                return com.mongodb.client.MongoClients.create(mongoConfiguration, DRIVER_INFORMATION);\n            }\n        });\n    }","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/MongoClients.java#L127-L163","documentation":"MongoClients.unmanagedMongoClient creates a one-off MongoClient from named config in quarkus.mongodb.clients. If the named client's 'active' flag is false, the client is intentionally disabled and Quarkus throws IllegalStateException rather than creating a connection. This prevents accidentally using a deliberately deactivated client configuration.","triggerScenarios":"Calling unmanagedMongoClient(\"name\") where quarkus.mongodb.clients.\"name\".active is set to false (or the config entry exists but is inactive).","commonSituations":"A named client was disabled in configuration (e.g. per-environment yml sets active: false) but code still requests it; profile-specific config deactivates the client in test/dev while production code expects it; copy-pasted client config with active=false left in place.","solutions":["Set quarkus.mongodb.clients.\"<name>\".active=true for the client in the active config profile","Remove the active=false override from profile-specific config (application.yaml for dev/test)","Rename the lookup to a client name that is active","If the client is intentionally inactive, guard the code path and skip creation instead of requesting it"],"exampleFix":"// before (application.properties)\nquarkus.mongodb.clients.legacy.active=false\n// after\nquarkus.mongodb.clients.legacy.active=true","handlingStrategy":"validation","validationCode":"MongoClientConfig cfg = config.clients().get(clientName);\nif (cfg == null || !cfg.active()) {\n    throw new IllegalArgumentException(\"Client '\" + clientName + \"' missing or inactive — set quarkus.mongodb.clients.\\\"\" + clientName + \"\\\".active=true\");\n}","typeGuard":"null","tryCatchPattern":"try {\n    MongoClient client = mongoClients.unmanagedMongoClient(name);\n} catch (IllegalStateException e) {\n    log.errorf(e, \"Mongo client '%s' is inactive; check quarkus.mongodb.clients.%s.active\", name, name);\n}","preventionTips":["Audit all profiles (dev/test/prod) for clients.*.active=false overrides","Keep named-client definitions in one config file to avoid profile drift","Add a startup smoke test that resolves every named client used by the app"],"tags":["mongodb","configuration","named-clients"],"backgroundTag":"inactive-client-config","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"}