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
GenerateYamlRegisteredServiceCommand logs this warning when the JSON service definition file passed to generateYaml does not exist, is unreadable, or is empty, so there is nothing to convert to YAML. The command catches any conversion error, logs it, and finishes without producing the YAML output.
Solutions
- Pass the correct absolute path to an existing JSON registered service file
- Verify the file is non-empty and readable (cat / ls -l the path)
- Check the current working directory when using relative paths
- Re-create or re-copy the JSON service definition if it is truncated
Example fix
// before cas generate-yaml-registered-service --file svc.json // after cas generate-yaml-registered-service --file /etc/cas/services/Example-1000.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 JSON file missing/empty/unreadable: " + path); Prevention
- Use absolute paths in scripts regardless of working directory
- Verify file size > 0 after copy/download before conversion
- Fix permissions on the services directory for the shell user
When it happens
Trigger: Running 'cas generate-yaml-registered-service' with --file pointing at a path that does not exist, has no read permission, or is a zero-byte file.
Common situations: Typo in the JSON service file path; relative path resolved from a different working directory; truncated/empty file from a failed copy or download; file created but serializer never wrote content.
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
- File [ ] is does not exist, is not readable or is empty
- Configuration file [ ] is not readable/writable or is not a…
- The service definition file could not be saved at
- subordinate directory
- subordinate directory
AI-assisted analysis of apereo/cas@e7288fc434 (2026-09-08).
Data as JSON: /api/errors/478fe3b601355c83.
Report an issue: GitHub.
Appendix: source
Thrown at support/cas-server-support-shell-core/src/main/java/org/apereo/cas/shell/commands/services/GenerateYamlRegisteredServiceCommand.java:74
try {
val validator = new RegisteredServiceJsonSerializer(applicationContext);
val basicFileAttributes = Files.readAttributes(filePath.toPath(), BasicFileAttributes.class);
if (basicFileAttributes.isRegularFile() && filePath.exists()
&& filePath.canRead() && basicFileAttributes.size() > 0) {
val svc = validator.from(filePath);
LOGGER.info("Service [{}] is valid at [{}].", svc.getName(), filePath.getCanonicalPath());
val yaml = new RegisteredServiceYamlSerializer(applicationContext);
try (val writer = new StringWriter()) {
yaml.to(writer, svc);
LOGGER.info(writer.toString());
if (result != null) {
yaml.to(result, svc);
LOGGER.info("YAML service definition is saved at [{}].", result.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)