alibaba/canal · error · RuntimeException

Read {}mapping config: {} error.

Error message

Read {}mapping config: {} error. 

What it means

Error "Read {}mapping config: {} error. " thrown in alibaba/canal.

Source

Thrown at client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/MappingConfigsLoader.java:39

            if (url != null) {
                configDir = new File(url.getPath() + name + File.separator);
            }
        }

        File[] files = configDir.listFiles();
        if (files != null) {
            for (File file : files) {
                String fileName = file.getName();
                if (!fileName.endsWith(".yml")) {
                    continue;
                }
                try (InputStream in = new FileInputStream(file)) {
                    byte[] bytes = new byte[in.available()];
                    in.read(bytes);
                    String configContent = new String(bytes, StandardCharsets.UTF_8);
                    configContentMap.put(fileName, configContent);
                } catch (IOException e) {
                    throw new RuntimeException("Read " + name + "mapping config: " + fileName + " error. ", e);
                }
            }
        }

        return configContentMap;
    }

    public static String loadConfig(String name) {
        // 先取本地文件,再取类路径
        File filePath = new File(".." + File.separator + Constant.CONF_DIR + File.separator + name);
        if (!filePath.exists()) {
            URL url = MappingConfigsLoader.class.getClassLoader().getResource("");
            if (url != null) {
                filePath = new File(url.getPath() + name);
            }
        }
        if (filePath.exists()) {
            String fileName = filePath.getName();

View on GitHub (pinned to 87be50e876)

Solutions

  1. Validate the mapping YAML file syntax (indentation, quoting) for the reported config path.
  2. Ensure the mapping file exists in conf/ (or the configured config dir) and is readable.
  3. Check the file encoding is UTF-8 without BOM.

When it happens

Trigger: Thrown at client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/MappingConfigsLoader.java:39 when the library encounters an invalid state.

Common situations: Failed reading an adapter mapping config. Include the file path and parse cause, validate required keys right after load, and fail startup on malformed YAML.


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