alibaba/canal · error · NullPointerException

dbMapping.table

Error message

dbMapping.table

What it means

Thrown by phoenix MappingConfig.validate() when dbMapping.table is null or empty. table is the source table name; without it the adapter cannot match events. Unlike the rdb adapter, phoenix has no mirrorDb exemption, so table is always required.

Source

Thrown at client-adapter/phoenix/src/main/java/com/alibaba/otter/canal/client/adapter/phoenix/config/MappingConfig.java:82

    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;                       // 是否允许删除字段
        private boolean limit = false;                      // 是否限制字段长度
        private boolean skipMissing = false;                // 是否跳过丢失的字段
        private boolean escapeUpper = true;                 // 字段默认大写加双引号

View on GitHub (pinned to 87be50e876)

Solutions

  1. Add a non-empty 'table:' under dbMapping in the failing phoenix yml.
  2. Ensure 'table' is indented as a child of dbMapping.

Example fix

# before
dbMapping:
  database: mytest
# after
dbMapping:
  database: mytest
  table: user
Defensive patterns

Strategy: validation

Validate before calling

DbMapping m = config.getDbMapping();
if (m == null || m.getTable() == null || m.getTable().isEmpty()) {
    throw new IllegalArgumentException("phoenix yml missing dbMapping.table for " + fileName);
}

Prevention

When it happens

Trigger: A phoenix mapping yml's dbMapping block omits or blanks 'table:'.

Common situations: Template copy with 'table:' removed or mis-indented.

Related errors


AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14). Data as JSON: /api/errors/07aa58293c366736. Report an issue: GitHub.