redis/jedis · error · IllegalArgumentException

file does not exist

Error message

%s file %s does not exist

What it means

SslOptions.assertFile validates that a configured SSL material file (e.g. truststore, keystore, cert) exists on disk. The keyword parameter names which file role failed. Thrown as IllegalArgumentException during client builder configuration.

Solutions

  1. Verify the path exists with 'new File(path).exists()' or ls before building the client.
  2. Use absolute paths instead of relative ones.
  3. In containers, ensure the file is mounted/copied into the image or volume.
  4. Check file permissions allow the JVM user to stat the file.

Example fix

// before
SslOptions.builder().trustStore(new File("/etc/ssl/nonexistent.jks")).build();
// after
File ts = new File("/etc/ssl/truststore.jks");
if (!ts.exists()) throw new IllegalStateException("truststore missing: " + ts);
SslOptions.builder().trustStore(ts).build();
Defensive patterns

Strategy: validation

Validate before calling

File f = new File(path);
if (!f.exists()) throw new IllegalStateException("missing SSL file: " + path);
if (!f.isFile()) throw new IllegalStateException("not a file: " + path);

Try / catch

try {
  SslOptions opts = SslOptions.builder().trustStore(f).build();
} catch (IllegalArgumentException e) {
  log.error("SSL config error: {}", e.getMessage());
}

Prevention

When it happens

Trigger: Passing a File path to SslOptions (e.g. trustStoreFile, keyStoreFile, or via builder sslOptions(...)) where the path does not exist on disk at client construction time.

Common situations: Typo in path, file only exists on another machine/container, working-directory differences between dev and prod, Docker volume not mounted, relative path resolved against unexpected cwd.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08). Data as JSON: /api/errors/1913ce1e50bf1bac. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/redis/clients/jedis/SslOptions.java:476

     */
    public SslVerifyMode getSslVerifyMode() {
        return sslVerifyMode;
    }

    private static char[] getPassword(char[] chars) {
        return chars != null ? Arrays.copyOf(chars, chars.length) : null;
    }

    /**
     * Assert that {@code file} {@link File#exists() exists}.
     *
     * @param keyword file recognizer
     * @param file
     * @throws IllegalArgumentException if the file doesn't exist
     */
    public static void assertFile(String keyword, File file) {
        if (!file.exists()) {
            throw new IllegalArgumentException(String.format("%s file %s does not exist", keyword, file));
        }
        if (!file.isFile()) {
            throw new IllegalArgumentException(String.format("%s file %s is not a file", keyword, file));
        }
    }

    /**
     * Supplier for a {@link InputStream} representing a resource. The resulting {@link InputStream} must be closed by
     * the calling code.
     */
    @FunctionalInterface
    public interface Resource {

        /**
         * Create a {@link Resource} that obtains a {@link InputStream} from a {@link URL}.
         *
         * @param url the URL to obtain the {@link InputStream} from.
         * @return a {@link Resource} that opens a connection to the URL and obtains the {@link InputStream} for it.

View on GitHub (pinned to 6dac31d4c2)