apache/incubator-seata · critical · IllegalArgumentException

file not found

Error message

file not found

What it means

YamlFileConfig's constructor throws IllegalArgumentException('file not found') when opening the given File raises FileNotFoundException. Seata selects a YAML parser (via FileConfigFactory YAML_TYPE) when the config file name ends in .yml/.yaml; if the resolved File object does not point to an existing readable file, FileInputStream fails and this wrapper error surfaces during configuration bootstrap.

Source

Thrown at config/seata-config-core/src/main/java/org/apache/seata/config/file/YamlFileConfig.java:45

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

@LoadLevel(name = FileConfigFactory.YAML_TYPE, order = 1, scope = Scope.PROTOTYPE)
public class YamlFileConfig implements FileConfig {

    private static final Logger LOGGER = LoggerFactory.getLogger(YamlFileConfig.class);
    private final Map<String, Object> configMap = new HashMap<>();

    public YamlFileConfig(File file, String name) throws IOException {
        Yaml yaml = new Yaml();
        try (InputStream is = new FileInputStream(file)) {
            flattenConfig("", yaml.loadAs(is, HashMap.class), configMap);
        } catch (FileNotFoundException e) {
            throw new IllegalArgumentException("file not found");
        }
    }

    private void flattenConfig(String prefix, Map<String, Object> config, Map<String, Object> flatMap) {
        for (Map.Entry<String, Object> entry : config.entrySet()) {
            String key = prefix.isEmpty() ? entry.getKey() : prefix + "." + entry.getKey();
            Object value = entry.getValue();
            if (value != null) {
                if (value instanceof Map) {
                    flattenConfig(key, (Map<String, Object>) value, flatMap);
                } else {
                    flatMap.put(key, String.valueOf(value));
                }
            }
        }
    }

    @Override

View on GitHub (pinned to e01f97c6db)

Solutions

  1. Verify the exact path: log File.getAbsolutePath() before loading and confirm the file exists there.
  2. Fix the configured name (config.file.name / seata.config.name) to point at the shipped .yml file.
  3. If loading from the classpath, ensure the yml is under src/main/resources so it lands in the artifact.
  4. For external files, use absolute paths or the 'file:' prefix supported by the resolver.

Example fix

# before
seata.config.name = classpath:application.yml  # file missing from resources

# after
# add src/main/resources/application.yml to the artifact, or point to an absolute path
seata.config.name = file:/etc/seata/application.yml
Defensive patterns

Strategy: validation

Validate before calling

File f = new File(path);
if (!f.isFile() || !f.canRead()) {
    throw new IllegalStateException("config file missing or unreadable: " + f.getAbsolutePath());
}

Prevention

When it happens

Trigger: Config file name set to a .yml path that does not exist on the filesystem or classpath resolution produced a wrong path; the file was present at build time but excluded from the deployed jar; relative path resolved against a different working directory (e.g. running seata from a service wrapper); file exists but is unreadable/permissions or is a directory.

Common situations: application.yml named in file.conf's config.file.name but missing from Docker image; -Dseata.config.name=path/to/config.yml with a typo; Kubernetes ConfigMount path differing from the configured name; moving from file.conf to registry.yml and forgetting to ship the file.

Related errors


AI-assisted analysis of apache/incubator-seata@e01f97c6db (2026-08-14). Data as JSON: /api/errors/ca8527f4c6e94de6. Report an issue: GitHub.