{"record":{"id":"c9c095531813eb88","repo":"apache/cassandra","slug":"unable-to-locate-filename","errorCode":null,"errorMessage":"unable to locate ${filename}","messagePattern":"unable to locate (.+?)","errorType":"exception","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/utils/FBUtilities.java","lineNumber":413,"sourceCode":"                    }\n                    return o2.compareTo(o1);\n                }\n            };\n            Collections.sort(keys, comparator);\n        }\n        else\n        {\n            // unwrapped range (left < right).  standard sort is all we need.\n            Collections.sort(keys);\n        }\n    }\n\n    public static String resourceToFile(String filename) throws ConfigurationException\n    {\n        ClassLoader loader = FBUtilities.class.getClassLoader();\n        URL scpurl = loader.getResource(filename);\n        if (scpurl == null)\n            throw new ConfigurationException(\"unable to locate \" + filename);\n\n        return new File(scpurl.getFile()).absolutePath();\n    }\n\n    public static File cassandraTriggerDir()\n    {\n        File triggerDir = null;\n        if (TRIGGERS_DIR.getString() != null)\n        {\n            triggerDir = new File(TRIGGERS_DIR.getString());\n        }\n        else\n        {\n            URL confDir = FBUtilities.class.getClassLoader().getResource(DEFAULT_TRIGGER_DIR);\n            if (confDir != null)\n                triggerDir = new File(confDir.getFile());\n        }\n        if (triggerDir == null || !triggerDir.exists())","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/utils/FBUtilities.java#L395-L431","documentation":"FBUtilities.resourceToFile locates a classpath resource and returns its absolute file path. If the ClassLoader cannot find the resource, it throws ConfigurationException indicating the resource name could not be located.","triggerScenarios":"resourceToFile(\"cassandra-rackdc.properties\") (or similar) where the file is absent from the classpath/conf directory or the name is mistyped.","commonSituations":"Incomplete deployments missing conf files, files renamed or moved between Cassandra versions, running with a classpath that excludes the conf directory, misconfigured snitch/property file references.","solutions":["Place the requested resource in the conf/ directory (or on the classpath) with the exact name expected","Verify the file name/spelling and that it exists: ls conf/ and compare with the requested filename","Check the process's classpath (-cp / CASSANDRA_CONF) includes the directory containing the resource"],"exampleFix":"// before\nString path = FBUtilities.resourceToFile(\"cassandra-rackdc.properties\"); // missing\n// after\n// ensure conf/cassandra-rackdc.properties exists and conf is on classpath\nString path = FBUtilities.resourceToFile(\"cassandra-rackdc.properties\");","handlingStrategy":"validation","validationCode":"boolean resourceExists(String name) {\n    return FBUtilities.class.getClassLoader().getResource(name) != null;\n}","typeGuard":null,"tryCatchPattern":"try {\n    String path = FBUtilities.resourceToFile(\"cassandra-rackdc.properties\");\n} catch (ConfigurationException e) {\n    log.error(\"Missing required classpath resource: {}\", e.getMessage());\n    // abort startup or fall back to defaults\n}","preventionTips":["Ship all expected conf/ resources with the deployment","Verify classpath includes the conf directory (CASSANDRA_CONF)","Match resource names exactly to the version's expected file names"],"tags":["classpath","resource","configuration","file-not-found","java"],"backgroundTag":"resource-not-found","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}