apereo/cas · warning
Unable to create folder
Error message
Unable to create folder [{}] What it means
CasServiceRegistryInitializationConfiguration.getServiceRegistryInitializerServicesDirectoryResource materializes embedded classpath service definitions to a temp directory (java.io.tmpdir/cas). If File.mkdirs() fails and the folder does not already exist, this warning is logged; startup continues but materializing default services may fail downstream.
Solutions
- Ensure the temp directory (java.io.tmpdir, typically /tmp) is writable by the CAS process user; set -Djava.io.tmpdir to a writable path if not.
- Free disk space or raise the quota if tmpfs is full.
- In containers, mount an writable emptyDir at /tmp or disable readOnlyRootFilesystem for the CAS container.
Example fix
// before (k8s container)
volumes: []
// after
volumes:
- name: tmp
emptyDir: {}
volumeMounts:
- name: tmp
mountPath: /tmp Defensive patterns
Strategy: validation
Validate before calling
// Startup pre-check
File tmp = new File(System.getProperty("java.io.tmpdir"), "cas");
if (!tmp.exists() && !tmp.mkdirs()) {
throw new IllegalStateException("Cannot create CAS temp dir: " + tmp + "; check java.io.tmpdir writability");
} Prevention
- Ensure the container/CAS user can write to java.io.tmpdir; override -Djava.io.tmpdir if needed.
- Mount writable tmp (emptyDir) in containers with readOnlyRootFilesystem.
- Monitor disk space/quota on the tmp filesystem.
When it happens
Trigger: CAS startup with default/embedded JSON service registry location where new File(FileUtils.getTempDirectory(), "cas").mkdirs() fails — parent.mkdirs() returns false and parent.exists() is false; called via location() during the service registry initializer bean setup.
Common situations: Read-only or full tmp directory (readOnlyRootFilesystem in k8s, TMPDIR pointing to unwritable path); disk quota exceeded; restrictive permissions on java.io.tmpdir.
Understand the failure class
Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.
Related errors
- subordinate directory
- subordinate directory
- Cannot read/load from subordinate directory
- Metadata directory location cannot be located/created
- Unable to create folder
AI-assisted analysis of apereo/cas@e7288fc434 (2026-09-08).
Data as JSON: /api/errors/a768766a5de77e52.
Report an issue: GitHub.
Appendix: source
Thrown at core/cas-server-core-services/src/main/java/org/apereo/cas/config/CasServiceRegistryInitializationConfiguration.java:122
}
}
@Configuration(value = "CasServiceRegistryEmbeddedConfiguration", proxyBeanMethods = false)
@EnableConfigurationProperties(CasConfigurationProperties.class)
static class CasServiceRegistryEmbeddedConfiguration {
private static Resource getServiceRegistryInitializerServicesDirectoryResource(
final CasConfigurationProperties casProperties,
final ConfigurableApplicationContext applicationContext) {
val registry = casProperties.getServiceRegistry().getJson();
if (ResourceUtils.doesResourceExist(registry.getLocation())
|| (ResourceUtils.isJarResource(registry.getLocation()) && !registry.isUsingDefaultLocation())) {
LOGGER.debug("Using JSON service registry location [{}] for embedded service definitions", registry.getLocation());
return registry.getLocation();
}
val parent = new File(FileUtils.getTempDirectory(), "cas");
if (!parent.mkdirs() && !parent.exists()) {
LOGGER.warn("Unable to create folder [{}]", parent);
}
val baseName = FilenameUtils.getBaseName(registry.getLocation().getFilename());
val patterns = Arrays.stream(applicationContext.getEnvironment().getActiveProfiles())
.map(profile -> String.format("classpath*:/%s/%s/*.json", baseName, profile))
.collect(Collectors.toList());
if (casProperties.getServiceRegistry().getCore().isInitDefaultServices()) {
patterns.add("classpath*:/services/*.json");
}
LOGGER.debug("Patterns to scan for embedded service definitions: [{}]", patterns);
ResourceUtils.exportResources(applicationContext, parent, patterns);
LOGGER.debug("Using service registry location [{}] for embedded service definitions", parent);
return new FileSystemResource(parent);
}
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@Bean
public ServiceRegistry embeddedJsonServiceRegistry(View on GitHub (pinned to e7288fc434)