quarkusio/quarkus · critical · IllegalArgumentException
Config property 'quarkus.mongodb.database' must be defined w
Error message
Config property 'quarkus.mongodb.database' must be defined when no database exist in the connection string
What it means
LiquibaseMongodbFactory.createLiquibase needs a database name for the Liquibase MongoDB database handle. It first checks the quarkus.mongodb.database config; if absent it tries to extract the database from the connection string via a regex, and if neither exists it throws this IllegalArgumentException. The message is explicit: MongoDB connection strings can be database-less (e.g. mongodb://host:27017), so the database must be configured.
Source
Thrown at extensions/liquibase/liquibase-mongodb/runtime/src/main/java/io/quarkus/liquibase/mongodb/LiquibaseMongodbFactory.java:122
if (changeLog.startsWith("classpath:")) {
return StringUtil.changePrefix(changeLog, "classpath:", "");
}
return changeLog;
}
public Liquibase createLiquibase() {
try (ResourceAccessor resourceAccessor = resolveResourceAccessor()) {
MongoClients mongoClients = Arc.container().instance(MongoClients.class).get();
String parsedChangeLog = parseChangeLog(liquibaseMongodbBuildTimeConfig.changeLog());
String connectionString = mongoClientConfig.connectionString().orElse("mongodb://localhost:27017");
Matcher matcher = HAS_DB.matcher(connectionString);
Optional<String> maybeDatabase = mongoClientConfig.database();
if (maybeDatabase.isEmpty()) {
if (matcher.matches() && !StringUtil.isNullOrEmpty(matcher.group("db"))) {
maybeDatabase = Optional.of(matcher.group("db"));
} else {
throw new IllegalArgumentException("Config property 'quarkus.mongodb.database' must " +
"be defined when no database exist in the connection string");
}
}
Database database = createDatabase(mongoClients, clientName, maybeDatabase.get());
if (liquibaseMongodbConfig.liquibaseCatalogName().isPresent()) {
database.setLiquibaseCatalogName(liquibaseMongodbConfig.liquibaseCatalogName().get());
}
if (liquibaseMongodbConfig.liquibaseSchemaName().isPresent()) {
database.setLiquibaseSchemaName(liquibaseMongodbConfig.liquibaseSchemaName().get());
}
if (liquibaseMongodbConfig.liquibaseTablespaceName().isPresent()) {
database.setLiquibaseTablespaceName(liquibaseMongodbConfig.liquibaseTablespaceName().get());
}
if (liquibaseMongodbConfig.defaultCatalogName().isPresent()) {
database.setDefaultCatalogName(liquibaseMongodbConfig.defaultCatalogName().get());
}
if (liquibaseMongodbConfig.defaultSchemaName().isPresent()) {
database.setDefaultSchemaName(liquibaseMongodbConfig.defaultSchemaName().get());View on GitHub (pinned to e1c734241f)
Solutions
- Set the database in application.properties, e.g. quarkus.mongodb.database=mydb (or quarkus.mongodb.<client-name>.database for a named client)
- Alternatively append the database to the connection string: mongodb://user:pass@host:27017/mydb or mongodb+srv://cluster/host/mydb
- If multiple clients exist, make sure the config is set for the client Liquibase is targeting, not just the default
- Confirm the Liquibase startup actions are intended for that client and that its config block exists
Example fix
# before quarkus.mongodb.connection-string=mongodb://localhost:27017 # after quarkus.mongodb.connection-string=mongodb://localhost:27017 quarkus.mongodb.database=inventory
Defensive patterns
Strategy: validation
Validate before calling
// Fail fast at startup if the DB name is neither in config nor in the connection string
String cs = config.getValue("quarkus.mongodb.connection-string");
String db = config.getOptionalValue("quarkus.mongodb.database", String.class).orElse(null);
String dbFromCs = null;
if (cs != null) {
java.net.URI u = java.net.URI.create(cs);
String p = u.getPath();
if (p != null && p.length() > 1) dbFromCs = p.substring(1);
}
if ((db == null || db.isBlank()) && (dbFromCs == null || dbFromCs.isBlank())) {
throw new IllegalArgumentException("Set quarkus.mongodb.database or append the database to the connection string");
} Try / catch
try {
liquibaseMongodbFactory.createLiquibase();
} catch (IllegalArgumentException e) {
if (e.getMessage() != null && e.getMessage().contains("quarkus.mongodb.database")) {
// supply the database name or append it to the connection string
}
throw e;
} Prevention
- Always set quarkus.mongodb.database when using database-less connection strings
- Include the database in the connection string (mongodb://host:27017/mydb) as the single source of truth
- Check per-client keys (quarkus.mongodb.<name>.database) when using named clients
- Smoke-test startup locally with MongodbStartActions enabled before deploying
When it happens
Trigger: quarkus.liquibase-mongodb.start-actions is enabled, the connection string in quarkus.mongodb.connection-string has no database segment, and quarkus.mongodb.database is not set — LiquibaseMongodbFactory.createLiquibase (invoked from doStartActions at startup) throws.
Common situations: Developers configure only mongodb://localhost:27017 without quarkus.mongodb.database; connecting to Atlas with a SRV string lacking the /database part; a named client (quarkus.mongodb.<name>.) where only the default config was filled in; enabling Liquibase MongodbStartActions on an app that never needed a default DB.
Related errors
- <errorMessage>.formatted(clientName) (required Liquibase Mon
- Mongo client named '%s' not found
- Error starting Liquibase
- '%s' property must be configured
- Unable to find top command. Ensure you have a @CommandDefini
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/7cc7196428175ad3.
Report an issue: GitHub.