apache/flink · error · FileNotFoundException

Properties file {} does not exist

Error message

Properties file {} does not exist

What it means

ParameterTool.fromPropertiesFile(File) checks file.exists() first and throws FileNotFoundException with the absolute path when the properties file is missing, before attempting to open it. The absolute path in the message disambiguates relative-path issues (cwd-dependent resolution). The IOException signature also covers read failures afterwards.

Source

Thrown at flink-core/src/main/java/org/apache/flink/util/ParameterTool.java:117

     * @throws IOException If the file does not exist
     * @see Properties
     */
    public static ParameterTool fromPropertiesFile(String path) throws IOException {
        File propertiesFile = new File(path);
        return fromPropertiesFile(propertiesFile);
    }

    /**
     * Returns {@link ParameterTool} for the given {@link Properties} file.
     *
     * @param file File object to the properties file
     * @return A {@link ParameterTool}
     * @throws IOException If the file does not exist
     * @see Properties
     */
    public static ParameterTool fromPropertiesFile(File file) throws IOException {
        if (!file.exists()) {
            throw new FileNotFoundException(
                    "Properties file " + file.getAbsolutePath() + " does not exist");
        }
        try (FileInputStream fis = new FileInputStream(file)) {
            return fromPropertiesFile(fis);
        }
    }

    /**
     * Returns {@link ParameterTool} for the given InputStream from {@link Properties} file.
     *
     * @param inputStream InputStream from the properties file
     * @return A {@link ParameterTool}
     * @throws IOException If the file does not exist
     * @see Properties
     */
    public static ParameterTool fromPropertiesFile(InputStream inputStream) throws IOException {
        Properties props = new Properties();
        props.load(inputStream);

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Check the absolute path in the message — usually the cwd assumption is wrong.
  2. Use an absolute path, or resolve against a known base (user.dir, an app home property).
  3. For classpath resources, load via getClass().getClassLoader().getResourceAsStream(...) and use fromPropertiesFile(InputStream) instead.
  4. Create/default the file before reading if it is expected to be generated.

Example fix

// before
ParameterTool p = ParameterTool.fromPropertiesFile(new File("conf/job.properties"));

// after
try (InputStream in = getClass().getClassLoader().getResourceAsStream("job.properties")) {
    ParameterTool p = ParameterTool.fromPropertiesFile(in);
}
Defensive patterns

Strategy: validation

Validate before calling

File f = new File(path);
if (!f.isFile()) { throw new FileNotFoundException("config not found at " + f.getAbsolutePath() + " (cwd=" + System.getProperty("user.dir") + ")"); }

Try / catch

catch (FileNotFoundException e) { try classpath fallback: InputStream in = loader.getResourceAsStream(basename); if (in != null) return ParameterTool.fromPropertiesFile(in); throw e; }

Prevention

When it happens

Trigger: Calling fromPropertiesFile(new File(path)) where path is wrong, relative to a different working directory, or the file is not yet created (ordering issue in setup code).

Common situations: Running the jar from a different directory than assumed; file packaged under resources but addressed as a filesystem path; path built from a config key that was not set (defaults like null/"" resolving to a bogus location).

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/3918a268971b8245. Report an issue: GitHub.