alibaba/canal · error · NullPointerException
dbMapping.targetTable
Error message
dbMapping.targetTable
What it means
Thrown by phoenix MappingConfig.validate() when dbMapping.targetTable is null or empty. targetTable is the destination Phoenix table name where data is written; it is always required for phoenix mappings.
Source
Thrown at client-adapter/phoenix/src/main/java/com/alibaba/otter/canal/client/adapter/phoenix/config/MappingConfig.java:85
}
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; // 是否允许删除字段
private boolean limit = false; // 是否限制字段长度
private boolean skipMissing = false; // 是否跳过丢失的字段
private boolean escapeUpper = true; // 字段默认大写加双引号
private String targetDb; // 目标库名
private String targetTable; // 目标表名View on GitHub (pinned to 87be50e876)
Solutions
- Add a non-empty 'targetTable:' under dbMapping (e.g. 'mytest.user').
- Verify indentation under dbMapping.
Example fix
# before dbMapping: database: mytest table: user # after dbMapping: database: mytest table: user targetTable: mytest.user
Defensive patterns
Strategy: validation
Validate before calling
DbMapping m = config.getDbMapping();
if (m == null || m.getTargetTable() == null || m.getTargetTable().isEmpty()) {
throw new IllegalArgumentException("phoenix yml missing dbMapping.targetTable for " + fileName);
} Prevention
- Always set targetTable in phoenix yml (e.g. schema.table).
- Lint phoenix yml files in CI.
When it happens
Trigger: A phoenix mapping yml's dbMapping block omits or blanks 'targetTable:'.
Common situations: Template missing 'targetTable:', or a value like 'targetTable: ""'.
Related errors
- dbMapping.database
- dbMapping.table
- KuduMapping.database
- ERROR Config: {fileName} {errorMessage}
- dbMapping.database
AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14).
Data as JSON: /api/errors/adeda1f85ccfabd2.
Report an issue: GitHub.