{"record":{"id":"b8af0c68d043f964","repo":"apereo/cas","slug":"unable-to-create-folder-b8af0c","errorCode":null,"errorMessage":"Unable to create folder [{}]","messagePattern":"Unable to create folder \\[(.+?)\\]","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/ResourceUtils.java","lineNumber":190,"sourceCode":"        }\n        return resource;\n    }\n\n    /**\n     * Export classpath resource to file.\n     *\n     * @param parentDirectory the parent directory\n     * @param resource        the resource\n     * @return the resource\n     */\n    public static @Nullable Resource exportClasspathResourceToFile(final File parentDirectory, final Resource resource) {\n        LOGGER.trace(\"Preparing classpath resource [{}]\", resource);\n        if (resource == null) {\n            LOGGER.warn(\"No resource defined to prepare.\");\n            return null;\n        }\n        if (!parentDirectory.exists() && !parentDirectory.mkdirs()) {\n            LOGGER.warn(\"Unable to create folder [{}]\", parentDirectory);\n        }\n        val destination = new File(parentDirectory, Objects.requireNonNull(resource.getFilename()));\n        FunctionUtils.doUnchecked(_ -> {\n            if (destination.exists()) {\n                LOGGER.trace(\"Deleting resource directory [{}]\", destination);\n                FileUtils.deleteQuietly(destination);\n            }\n            try (val out = new FileOutputStream(destination);\n                 val input = resource.getInputStream()) {\n                input.transferTo(out);\n            }\n        });\n        return new FileSystemResource(destination);\n    }\n\n\n    /**\n     * Prepare classpath resource if needed file.","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/apereo/cas/blob/e7288fc434b4f4505b8452e1a57e8fb3111bb863/core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/ResourceUtils.java#L172-L208","documentation":"A logged warning in ResourceUtils.exportClasspathResourceToFile issued when the target parent directory does not exist and File.mkdirs() fails to create it. Execution continues anyway, so the subsequent file write into that directory will likely fail downstream.","triggerScenarios":"Calling exportClasspathResourceToFile(parentDirectory, resource) where parentDirectory does not exist and cannot be created — e.g. the path points inside a read-only filesystem, a file already exists at that path, or permission to create directories is missing.","commonSituations":"CAS configured to export resources into /etc/cas/... or a container volume that is mounted read-only; running as a non-root user without write permission on the parent path; a stale file occupying the intended directory path.","solutions":["Ensure the parent directory exists and is writable by the CAS process user before startup (mkdir -p and chown).","Check filesystem mount flags — remount read-only volumes read-write or pick another destination.","Verify no regular file exists at the directory path; remove or rename it.","Run the container/JVM with sufficient filesystem permissions (e.g. non-root user with correct volume ownership)."],"exampleFix":"// before\nFile dir = new File(\"/etc/cas/templates\"); // may not be writable\nResourceUtils.exportClasspathResourceToFile(dir, resource);\n// after\nFile dir = new File(\"/etc/cas/templates\");\nif (!dir.exists() && !dir.mkdirs()) {\n    throw new IllegalStateException(\"Cannot create directory \" + dir);\n}\nResourceUtils.exportClasspathResourceToFile(dir, resource);","handlingStrategy":"validation","validationCode":"File dir = parentDirectory;\nif (!dir.exists()) {\n    if (!dir.mkdirs()) {\n        throw new IllegalStateException(\"Cannot create directory \" + dir + \"; check permissions/mounts\");\n    }\n}\nif (!dir.canWrite()) {\n    throw new IllegalStateException(\"Directory not writable: \" + dir);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-create export directories in deployment scripts/Dockerfile with correct ownership.","Run CAS as a user with write access to configured export paths.","Check volume mount flags (read-only) in containerized deployments.","Monitor logs for 'Unable to create folder' warnings during startup checks."],"tags":["filesystem","mkdir","permissions"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"e7288fc434b4f4505b8452e1a57e8fb3111bb863","analyzedAt":"2026-09-08T15:39:16.015Z","contentChangedAt":"2026-09-08T15:39:16.015Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}