alibaba/canal · error · NullPointerException
dbMapping.targetTable
Error message
dbMapping.targetTable
What it means
Thrown by MappingConfig.validate() when dbMapping.targetTable is null or empty. This identifies the destination table name in Alibaba Tablestore (OTS). It is the third and final check in validate() — thrown only after database and table pass.
Source
Thrown at client-adapter/tablestore/src/main/java/com/alibaba/otter/canal/client/adapter/tablestore/config/MappingConfig.java:104
}
public Integer getThreads() {
return threads;
}
public void setThreads(Integer threads) {
this.threads = threads;
}
public void validate() {
if (dbMapping.database == null || dbMapping.database.isEmpty()) {
throw new NullPointerException("dbMapping.database");
}
if (dbMapping.table == null || dbMapping.table.isEmpty()) {
throw new NullPointerException("dbMapping.table");
}
if (dbMapping.targetTable == null || dbMapping.targetTable.isEmpty()) {
throw new NullPointerException("dbMapping.targetTable");
}
}
public static class ColumnItem {
private String targetColumn;
private String column;
private TablestoreFieldType type;
public String getColumn() {
return column;
}
public void setColumn(String column) {
this.column = column;
}View on GitHub (pinned to 87be50e876)
Solutions
- Add a non-empty `targetTable` value (the OTS table name) under dbMapping.
- Ensure the OTS table has been created in the Tablestore instance before deploying the config.
Example fix
// before dbMapping: database: mydb table: users // after dbMapping: database: mydb table: users targetTable: ots_users
Defensive patterns
Strategy: validation
Validate before calling
// Check dbMapping.targetTable before calling validate()
if (config.getDbMapping() == null
|| config.getDbMapping().getTargetTable() == null
|| config.getDbMapping().getTargetTable().isEmpty()) {
throw new IllegalArgumentException("dbMapping.targetTable is required and must not be empty");
} Type guard
null
Try / catch
try {
config.validate();
} catch (NullPointerException e) {
if ("dbMapping.targetTable".equals(e.getMessage())) {
logger.error("Missing required field: dbMapping.targetTable");
}
throw e;
} Prevention
- Always include a non-empty `targetTable` (OTS table name) under dbMapping.
- Verify the OTS table exists in the Tablestore instance before deploying the config.
- Add a pre-deploy validation step that checks all three required fields.
When it happens
Trigger: Loading a tablestore mapping config YAML where the dbMapping.targetTable field is absent, null, or an empty string.
Common situations: YAML file missing the `targetTable:` line; OTS table name was not provisioned yet when the config was written; indentation error; the config was partially filled and deployed prematurely.
Related errors
- dbMapping.database
- dbMapping.table
- ERROR Config: {fileName} {errorMessage}
- No tablestore adapter found for config key: {key}
- not allow to change outAdapterKey
AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14).
Data as JSON: /api/errors/0fd5e1789fc63dea.
Report an issue: GitHub.