{"record":{"id":"fdcf90bee04ebc48","repo":"dromara/Sa-Token","slug":"redisson-file","errorCode":null,"errorMessage":"未找到 Redisson 配置文件: ${file}","messagePattern":"未找到 Redisson 配置文件: (.+?)","errorType":"validation","errorClass":"SaTokenException","httpStatus":null,"severity":"critical","filePath":"sa-token-plugin/sa-token-alone-redisson/src/main/java/cn/dev33/satoken/dao/alone/SaAloneRedissonRegister.java","lineNumber":104,"sourceCode":"\t\t} catch (SaTokenException e) {\n\t\t\tthrow e;\n\t\t} catch (Exception e) {\n\t\t\tthrow new SaTokenException(\"解析 sa-token.alone-redisson 配置失败\", e);\n\t\t}\n\t}\n\n\tprivate static InputStream openFile(String file) throws Exception {\n\t\tString path = file.trim();\n\t\tResource resource;\n\t\tif (path.startsWith(\"classpath:\")) {\n\t\t\tresource = new ClassPathResource(path.substring(\"classpath:\".length()));\n\t\t} else if (path.startsWith(\"file:\")) {\n\t\t\tresource = new FileSystemResource(path.substring(\"file:\".length()));\n\t\t} else {\n\t\t\tresource = new ClassPathResource(path);\n\t\t}\n\t\tif (!resource.exists()) {\n\t\t\tthrow new SaTokenException(\"未找到 Redisson 配置文件: \" + file);\n\t\t}\n\t\treturn resource.getInputStream();\n\t}\n\n}\n","sourceCodeStart":86,"sourceCodeEnd":110,"githubUrl":"https://github.com/dromara/Sa-Token/blob/ac2c7f6e94a78573cf0bcb932dd8b04e68fad189/sa-token-plugin/sa-token-alone-redisson/src/main/java/cn/dev33/satoken/dao/alone/SaAloneRedissonRegister.java#L86-L110","documentation":"SaTokenException thrown by SaAloneRedissonRegister.openFile when the configured sa-token.alone-redisson.file resource does not exist. The path supports classpath:, file:, and bare-path conventions (bare and classpath: resolve via ClassPathResource, file: via FileSystemResource); if resource.exists() is false the register aborts before any yaml parsing.","triggerScenarios":"Setting sa-token.alone-redisson.file: alone-redisson.yaml when the file sits in src/main/resources of a module not on the classpath; typos in the filename; using file: with a relative path resolved from the process CWD rather than the project root; file packed but path case-mismatched on case-sensitive filesystems.","commonSituations":"Multi-module builds where the yaml lives in a sibling module; running a packaged jar while pointing at a source-tree relative path; Windows-developed path casing failing on Linux.","solutions":["Use an explicit prefix matching the location: classpath:alone-redisson.yaml for resources, file:/etc/app/alone-redisson.yaml for absolute filesystem paths.","Verify the file actually ships: unzip the jar and check BOOT-INF/classes, or run resource.exists() in a test.","Fix typos and casing in the filename to match exactly.","If the content is small, switch to the inline sa-token.alone-redisson.config string to remove file-resolution from the equation."],"exampleFix":"# before\nsa-token:\n  alone-redisson:\n    file: redisson.yaml   # not found on classpath\n\n# after\nsa-token:\n  alone-redisson:\n    file: classpath:alone-redisson.yaml   # matches src/main/resources/alone-redisson.yaml","handlingStrategy":"validation","validationCode":"Resource r = path.startsWith(\"file:\")\n    ? new FileSystemResource(path.substring(5))\n    : new ClassPathResource(path.replaceFirst(\"^classpath:\", \"\"));\nif (!r.exists()) { fail fast with a clear message; }","typeGuard":"boolean resourceExists(String file) { /* same resolution logic as openFile */ return resolve(file).exists(); }","tryCatchPattern":"try { register(); } catch (SaTokenException e) { if (e.getMessage().startsWith(\"未找到 Redisson 配置文件\")) { /* fix path/prefix */ } }","preventionTips":["Use explicit classpath:/file: prefixes instead of bare paths to avoid CWD ambiguity.","Add a build check that the configured file is packaged (exists in the jar's classes)."],"tags":["alone-redisson","resource-not-found","classpath","configuration"],"backgroundTag":null,"analyzedSha":"ac2c7f6e94a78573cf0bcb932dd8b04e68fad189","analyzedAt":"2026-08-14T14:36:10.271Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}