alibaba/canal · error · NullPointerException

dbMapping.table

Error message

dbMapping.table

What it means

Thrown by MappingConfig.validate() when dbMapping.table is null or empty. This identifies the source table name in the source database that canal should read binlog events for. It is the second check in validate() — thrown only after database passes validation.

Source

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

    public void setUpdateChangeColumns(Boolean updateChangeColumns) {
        this.updateChangeColumns = updateChangeColumns;
    }

    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;
        }

View on GitHub (pinned to 87be50e876)

Solutions

  1. Add a non-empty `table` value (the source MySQL/database table name) under dbMapping.
  2. Verify the YAML structure and indentation.

Example fix

// before
dbMapping:
  database: mydb
  targetTable: ots_users

// after
dbMapping:
  database: mydb
  table: users
  targetTable: ots_users
Defensive patterns

Strategy: validation

Validate before calling

// Check dbMapping.table before calling validate()
if (config.getDbMapping() == null
    || config.getDbMapping().getTable() == null
    || config.getDbMapping().getTable().isEmpty()) {
    throw new IllegalArgumentException("dbMapping.table is required and must not be empty");
}

Type guard

null

Try / catch

try {
    config.validate();
} catch (NullPointerException e) {
    if ("dbMapping.table".equals(e.getMessage())) {
        logger.error("Missing required field: dbMapping.table");
    }
    throw e;
}

Prevention

When it happens

Trigger: Loading a tablestore mapping config YAML where the dbMapping.table field is absent, null, or an empty string.

Common situations: YAML file missing the `table:` line under dbMapping; field was commented out; indentation issue; the config was generated from a template that did not fill in the source table name.

Related errors


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