apache/seatunnel · error · CatalogException
Failed to open MongoDB Catalog: ${e.getMessage()}
Error message
Failed to open MongoDB Catalog: ${e.getMessage()} What it means
MongodbCatalog.open creates the MongoDB client with MongoClients.create(baseUrl) and wraps any exception into a CatalogException 'Failed to open MongoDB Catalog: <message>'. This is the catalog's initialization step; failure usually means the connection string is malformed or the driver fails at client creation.
Source
Thrown at seatunnel-connectors-v2/connector-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/catalog/MongodbCatalog.java:60
private final String catalogName;
private final String baseUrl;
private transient MongoClient mongoClient;
private final String defaultDatabase;
public MongodbCatalog(String catalogName, String baseUrl, String defaultDatabase) {
this.catalogName = catalogName;
this.baseUrl = baseUrl;
this.defaultDatabase = defaultDatabase;
}
@Override
public void open() throws CatalogException {
try {
if (mongoClient == null) {
mongoClient = MongoClients.create(baseUrl);
}
} catch (Exception e) {
throw new CatalogException("Failed to open MongoDB Catalog: " + e.getMessage(), e);
}
}
@Override
public String name() {
return catalogName;
}
@Override
public String getDefaultDatabase() throws CatalogException {
return defaultDatabase;
}
@Override
public boolean databaseExists(String databaseName) throws CatalogException {
try {
return listDatabases().contains(databaseName);
} catch (Exception e) {View on GitHub (pinned to cf67b549a7)
Solutions
- Validate the MongoDB connection string format: mongodb://[user:pass@]host[:port][/db][?options] or mongodb+srv://.
- Check network/DNS resolution to the MongoDB hosts and that the SRV record exists for +srv URIs.
- Verify URI options (replicaSet, ssl, authSource) are supported by the driver version.
- Confirm username/password are URL-encoded if they contain special characters.
Example fix
// before url = "mongodb+srv:/host:27017"; // malformed scheme // after url = "mongodb+srv://host.example.com:27017/?replicaSet=rs0";
Defensive patterns
Strategy: try-catch
Validate before calling
// validate the MongoDB URI before open()
if (baseUrl == null || !(baseUrl.startsWith("mongodb://") || baseUrl.startsWith("mongodb+srv://"))) {
throw new IllegalArgumentException("Invalid MongoDB connection string: " + baseUrl);
} Try / catch
try { catalog.open(); } catch (CatalogException e) { log.error("Mongo catalog open failed: {}", e.getMessage(), e.getCause()); throw e; } Prevention
- Test the connection string with mongosh before configuring the catalog
- URL-encode credentials containing special characters
- Verify DNS/SRV records for mongodb+srv URIs
When it happens
Trigger: Calling catalog.open() when baseUrl is invalid/unparseable, or the driver throws during MongoClients.create (bad URI options, invalid SRV hostname, missing scheme).
Common situations: Typo in mongodb:// or mongodb+srv:// URI; unsupported URI options; DNS/seed discovery failures surfacing at client setup; empty or null baseUrl passed via catalog config.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- Failed to open catalog %s
- Failed to list databases
- CONNECT_FAILED
- Failed to open catalog ${catalogName}
- Failed to open catalog %s
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/b3c4a41f10786655.
Report an issue: GitHub.