alibaba/canal · error · NullPointerException

null metaManager

Error message

null metaManager

What it means

MetaLogPositionManager stores binlog positions through a CanalMetaManager (the metadata backend: memory, zookeeper, or file). The delegate is mandatory, so the constructor throws NullPointerException when metaManager is null. Without a meta backend there is nowhere to read or write positions.

Source

Thrown at parse/src/main/java/com/alibaba/otter/canal/parse/index/MetaLogPositionManager.java:26

import com.alibaba.otter.canal.meta.CanalMetaManager;
import com.alibaba.otter.canal.parse.exception.CanalParseException;
import com.alibaba.otter.canal.protocol.ClientIdentity;
import com.alibaba.otter.canal.protocol.position.LogPosition;
import com.alibaba.otter.canal.store.helper.CanalEventUtils;

/**
 * Created by yinxiu on 17/3/18. Email: marklin.hz@gmail.com
 */
public class MetaLogPositionManager extends AbstractLogPositionManager {

    private final static Logger    logger = LoggerFactory.getLogger(MetaLogPositionManager.class);

    private final CanalMetaManager metaManager;

    public MetaLogPositionManager(CanalMetaManager metaManager){
        if (metaManager == null) {
            throw new NullPointerException("null metaManager");
        }

        this.metaManager = metaManager;
    }

    @Override
    public void stop() {
        super.stop();

        if (metaManager.isStart()) {
            metaManager.stop();
        }
    }

    @Override
    public void start() {
        super.start();

View on GitHub (pinned to 87be50e876)

Solutions

  1. Confirm the CanalMetaManager bean is created and non-null before constructing MetaLogPositionManager.
  2. Ensure the meta manager's own dependencies (zkClient, data dir) are satisfied so its factory does not return null.
  3. Verify the meta module (com.alibaba.otter.canal.meta) is on the classpath.

Example fix

// before
new MetaLogPositionManager(null);

// after
CanalMetaManager meta = new MemoryCanalMetaManager(); // or ZooKeeper/file variant
new MetaLogPositionManager(Objects.requireNonNull(meta));
Defensive patterns

Strategy: validation

Validate before calling

CanalMetaManager meta = Objects.requireNonNull(metaManager, "metaManager");
new MetaLogPositionManager(meta);

Type guard

boolean hasMetaManager(CanalMetaManager m) { return m != null; }

Prevention

When it happens

Trigger: Constructing `new MetaLogPositionManager(metaManager)` with metaManager == null. Happens when the metadata manager bean (memory/zk/file) was not created or its factory returned null.

Common situations: Instance config selects the meta-type position manager but the underlying CanalMetaManager bean (e.g. ZooKeeperCanalMetaManager needing a zkClient) failed to build; Spring property omitted; classpath missing the meta module.

Related errors


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