alibaba/canal · error · NullPointerException

hbaseMapping.table

Error message

hbaseMapping.table

What it means

MappingConfig.validate() requires HbaseMapping.table (the source MySQL table name) to be non-null and non-empty. Missing or blank table throws NullPointerException at validate() time.

Source

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

    public HbaseMapping getHbaseMapping() {
        return hbaseMapping;
    }

    public void setHbaseMapping(HbaseMapping hbaseMapping) {
        this.hbaseMapping = hbaseMapping;
    }

    public AdapterMapping getMapping() {
        return hbaseMapping;
    }

    public void validate() {
        if (hbaseMapping.database == null || hbaseMapping.database.isEmpty()) {
            throw new NullPointerException("hbaseMapping.database");
        }
        if (hbaseMapping.table == null || hbaseMapping.table.isEmpty()) {
            throw new NullPointerException("hbaseMapping.table");
        }
        if (hbaseMapping.hbaseTable == null || hbaseMapping.hbaseTable.isEmpty()) {
            throw new NullPointerException("hbaseMapping.hbaseTable");
        }
        if (hbaseMapping.mode == null) {
            throw new NullPointerException("hbaseMapping.mode");
        }
        if (hbaseMapping.rowKey != null && hbaseMapping.rowKeyColumn != null) {
            throw new RuntimeException("已配置了复合主键作为RowKey,无需再指定RowKey列");
        }
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        MappingConfig config = (MappingConfig) o;

View on GitHub (pinned to 87be50e876)

Solutions

  1. Set 'table: <source_table_name>' under hbaseMapping.
  2. Confirm the value matches the actual MySQL table being synced.
  3. Fix YAML indentation so 'table' is a child of hbaseMapping.
  4. Lint the YAML before deploy.

Example fix

# before
hbaseMapping:
  database: mydb
  hbaseTable: user

# after
hbaseMapping:
  database: mydb
  table: t_user
  hbaseTable: user
Defensive patterns

Strategy: validation

Validate before calling

MappingConfig cfg = ...;
if (cfg.getHbaseMapping() == null
        || cfg.getHbaseMapping().getTable() == null
        || cfg.getHbaseMapping().getTable().isEmpty()) {
    throw new IllegalArgumentException("hbaseMapping.table is required");
}

Try / catch

try {
    config.validate();
} catch (NullPointerException e) {
    if ("hbaseMapping.table".equals(e.getMessage())) {
        logger.error("Add 'table: <source_table>' under hbaseMapping");
    }
    throw e;
}

Prevention

When it happens

Trigger: HBase mapping YAML omitting 'hbaseMapping.table' or setting it empty; loaded via MappingConfigLoader during adapter init.

Common situations: Incomplete mapping YAML after renaming the source table; indentation slip so 'table' is not under hbaseMapping.

Related errors


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