alibaba/canal · error · NullPointerException
dbMapping.database
Error message
dbMapping.database
What it means
Thrown by phoenix MappingConfig.validate() when dbMapping.database is null or empty. Validation runs during config load, so it fails at adapter startup. database is the source schema name used to match incoming events.
Source
Thrown at client-adapter/phoenix/src/main/java/com/alibaba/otter/canal/client/adapter/phoenix/config/MappingConfig.java:79
public String getDestination() {
return destination;
}
public void setDestination(String destination) {
this.destination = destination;
}
public boolean isDebug() {
return debug;
}
public void setDebug(boolean debug) {
this.debug = debug;
}
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 DbMapping {
private String database; // 数据库名或schema名
private String table; // 表名
private Map<String, String> targetPk = new LinkedHashMap<>(); // 目标表主键字段
private boolean mapAll = true; // 映射所有字段
private boolean alter = true; // 是否允许修改表
private boolean drop = false; // 是否允许删除字段View on GitHub (pinned to 87be50e876)
Solutions
- Add a non-empty 'database:' under dbMapping in the failing phoenix yml.
- Fix indentation so 'database' is a child of dbMapping.
Example fix
# before dbMapping: table: user # after dbMapping: database: mytest table: user
Defensive patterns
Strategy: validation
Validate before calling
DbMapping m = config.getDbMapping();
if (m == null || m.getDatabase() == null || m.getDatabase().isEmpty()) {
throw new IllegalArgumentException("phoenix yml missing dbMapping.database for " + fileName);
} Prevention
- Start new phoenix yml files from phoenix/phoenixtest_user.yml which has database/table/targetTable.
- Lint phoenix yml files in CI.
When it happens
Trigger: A phoenix mapping yml parses but its dbMapping block omits or blanks 'database:'.
Common situations: A copied template had 'database:' deleted, or indentation places 'database' outside the dbMapping block.
Related errors
- dbMapping.table
- dbMapping.targetTable
- KuduMapping.database
- ERROR Config: {fileName} {errorMessage}
- dbMapping.database
AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14).
Data as JSON: /api/errors/540a83647c0b3d79.
Report an issue: GitHub.