apereo/cas · warning

File [ ] is does not exist, is not readable or is empty

Error message

File [{}] is does not exist, is not readable or is empty

What it means

ValidateRegisteredServiceCommand.validate() logs this warning when the service definition file passed for validation does not exist, is not readable, or is empty. Without file content the command cannot deserialize the service, so it skips validation and logs an error path separately if parsing fails.

Solutions

  1. Pass the absolute path to an existing, non-empty service definition file
  2. Confirm read permissions on the file for the shell user
  3. Ensure the file actually contains a serialized service (JSON or YAML per extension)
  4. Use the .yaml/.yml extension only for YAML service definitions, .json for JSON

Example fix

// before
cas validate-registered-service --file /etc/cas/services/missing.json
// after
cas validate-registered-service --file /etc/cas/services/ExampleService-100.json
Defensive patterns

Strategy: validation

Validate before calling

File f = new File(path);
if (!f.isFile() || !f.canRead() || f.length() == 0)
    throw new IllegalArgumentException("Service file missing/empty/unreadable: " + path);

Prevention

When it happens

Trigger: Running 'cas validate-registered-service' with --file pointing at a missing path, unreadable file, or zero-byte file; the file extension selects the serializer (json default, yaml/yml for YAML).

Common situations: Wrong path or typo when validating service definitions; empty placeholder file created by an editor; permissions dropped after a deployment; testing validation before ever copying the service file to the host.

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 apereo/cas@e7288fc434 (2026-09-08). Data as JSON: /api/errors/ded3119721f4be24. Report an issue: GitHub.

Appendix: source

Thrown at support/cas-server-support-shell-core/src/main/java/org/apereo/cas/shell/commands/services/ValidateRegisteredServiceCommand.java:79

                FileUtils.listFiles(directoryPath, new String[]{"json", "yml", "yaml"}, false)
                    .forEach(this::validate);
            }
        }
    }

    private void validate(final File filePath) {
        try {
            val basicFileAttributes = Files.readAttributes(filePath.toPath(), BasicFileAttributes.class);
            if (basicFileAttributes.isRegularFile() && filePath.exists()
                && filePath.canRead() && basicFileAttributes.size() > 0) {
                val validator = switch (FilenameUtils.getExtension(filePath.getPath()).toLowerCase(Locale.ENGLISH)) {
                    case "yml", "yaml" -> new RegisteredServiceYamlSerializer(applicationContext);
                    default -> new RegisteredServiceJsonSerializer(applicationContext);
                };
                val svc = Objects.requireNonNull(validator).from(filePath);
                LOGGER.info("Service [{}] is valid at [{}].", svc.getName(), filePath.getCanonicalPath());
            } else {
                LOGGER.warn("File [{}] is does not exist, is not readable or is empty", filePath.getCanonicalPath());
            }
        } catch (final Exception e) {
            LOGGER.error("Could not understand and validate [{}]: [{}]", filePath.getPath(), e.getMessage());
        } finally {
            LOGGER.info("-".repeat(SEP_LINE_LENGTH));
        }
    }
}

View on GitHub (pinned to e7288fc434)