{"record":{"id":"543e7ef2b6e50564","repo":"quarkusio/quarkus","slug":"the-database-attribute-was-not-set-for-the-mongoe-543e7e","errorCode":null,"errorMessage":"The database attribute was not set for the @MongoEntity annotation and the database was not configured for the named Mongo Client via 'quarkus.mongodb.%s.database' or the connection string","messagePattern":"The database attribute was not set for the @MongoEntity annotation and the database was not configured for the named Mongo Client via 'quarkus\\.mongodb\\.(.+?)\\.database' or the connection string","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/runtime/BeanUtils.java","lineNumber":75,"sourceCode":"        }\n        if (mongoClientConfig.connectionString().isPresent()) {\n            String database = new ConnectionString(mongoClientConfig.connectionString().get()).getDatabase();\n            if (database != null) {\n                return database;\n            }\n        }\n\n        if (mongoEntity == null) {\n            throw new IllegalArgumentException(\n                    \"The database was not configured for the default Mongo Client via 'quarkus.mongodb.database' \"\n                            + \"or the connection string\");\n        }\n        if (mongoEntity.clientName().isEmpty()) {\n            throw new IllegalArgumentException(\"The database attribute was not set for the @MongoEntity annotation \"\n                    + \"and the database was not configured for the default Mongo Client via 'quarkus.mongodb.database' \"\n                    + \"or the connection string\");\n        }\n        throw new IllegalArgumentException(String.format(\n                \"The database attribute was not set for the @MongoEntity annotation and the database was not configured \"\n                        + \"for the named Mongo Client via 'quarkus.mongodb.%s.database' or the connection string\",\n                mongoEntity.clientName()));\n    }\n\n    public static Optional<String> getDatabaseNameFromResolver() {\n        return Optional.of(Arc.container().select(MongoDatabaseResolver.class))\n                .filter(Predicate.not(InjectableInstance::isUnsatisfied))\n                .map(InjectableInstance::get)\n                .map(MongoDatabaseResolver::resolve)\n                .filter(Predicate.not(String::isBlank));\n    }\n\n    private static <T> T firstInstanceWithoutQualifier(Iterable<InstanceHandle<T>> handles,\n            Class<? extends Annotation> qualifier) {\n        for (InstanceHandle<T> handle : handles) {\n            InjectableBean<T> bean = handle.getBean();\n            boolean match = false;","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/runtime/BeanUtils.java#L57-L93","documentation":"The entity's @MongoEntity points at a named Mongo client (clientName is non-empty), but neither the annotation's database attribute, the named client's 'quarkus.mongodb.<clientName>.database' property, nor that client's connection string provides a database name.","triggerScenarios":"Entity annotated @MongoEntity(clientName=\"orders\") with no database attribute, while 'quarkus.mongodb.orders.database' is unset and 'quarkus.mongodb.orders.connection-string' has no /database path part.","commonSituations":"Multi-client setups where developers configure the named client's hosts but forget its database; copying the default client's config pattern and omitting the per-client database; typos in the client property name so the named config is never picked up.","solutions":["Set 'quarkus.mongodb.<clientName>.database=mydb' in application.properties (e.g. quarkus.mongodb.orders.database)","Set the database on the annotation: @MongoEntity(clientName=\"orders\", database=\"mydb\")","Embed the database in the named client's connection string: quarkus.mongodb.orders.connection-string=mongodb://host:27017/mydb"],"exampleFix":"// before (application.properties)\nquarkus.mongodb.orders.connection-string=mongodb://orders-host:27017\n\n// after\nquarkus.mongodb.orders.connection-string=mongodb://orders-host:27017\nquarkus.mongodb.orders.database=ordersdb","handlingStrategy":"validation","validationCode":"MongoEntity anno = MyEntity.class.getAnnotation(MongoEntity.class);\nString client = anno != null ? anno.clientName() : \"\";\nif (!client.isEmpty()\n        && config.getOptionalValue(\"quarkus.mongodb.\" + client + \".database\", String.class).isEmpty()) {\n    throw new IllegalStateException(\"Named client '\" + client + \"' has no database configured\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    repository.find(\"byName\", name).firstResult();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"named Mongo Client\")) {\n        log.error(\"Missing quarkus.mongodb.<client>.database for named client\", e);\n    }\n    throw e;\n}","preventionTips":["For every named client (quarkus.mongodb.<name>.*), also define quarkus.mongodb.<name>.database","Double-check clientName spelling matches the config key exactly","Use Quarkus dev services / config mapping validation at startup to catch unconfigured named clients early"],"tags":["mongodb","panache","configuration","named-client"],"backgroundTag":"missing-config-property","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"}