{"record":{"id":"f8b667e8693515fc","repo":"stanfordnlp/CoreNLP","slug":"error-cannot-find-properties-file-prefix-in","errorCode":null,"errorMessage":"ERROR: cannot find properties file \"${prefix}\" in the classpath!","messagePattern":"ERROR: cannot find properties file \"(.+?)\" in the classpath!","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"critical","filePath":"src/edu/stanford/nlp/pipeline/StanfordCoreNLP.java","lineNumber":423,"sourceCode":"  /**\n   * Finds the properties file in the classpath and loads the properties from there.\n   *\n   * @return The found properties object (must be not-null)\n   * @throws RuntimeException If no properties file can be found on the classpath\n   */\n  private static Properties loadPropertiesFromClasspath() {\n    List<String> validNames = Arrays.asList(\"StanfordCoreNLP\", \"edu.stanford.nlp.pipeline.StanfordCoreNLP\");\n    for (String name : validNames) {\n      Properties props = loadProperties(name);\n      if (props != null) return props;\n    }\n    throw new RuntimeException(\"ERROR: Could not find properties file in the classpath!\");\n  }\n\n  private static Properties loadPropertiesOrException(String propsFileNamePrefix) {\n    Properties props = loadProperties(propsFileNamePrefix);\n    if (props == null) {\n      throw new RuntimeIOException(\"ERROR: cannot find properties file \\\"\" + propsFileNamePrefix + \"\\\" in the classpath!\");\n    }\n    return props;\n  }\n\n  private static Properties loadProperties(String name) {\n    return loadProperties(name, Thread.currentThread().getContextClassLoader());\n  }\n\n  private static Properties loadProperties(String name, ClassLoader loader) {\n    // check if name represents a Stanford CoreNLP supported language\n    if (LanguageInfo.isStanfordCoreNLPSupportedLang(name))\n      name = LanguageInfo.getLanguagePropertiesFile(name);\n    if(name.endsWith (PROPS_SUFFIX)) name = name.substring(0, name.length () - PROPS_SUFFIX.length ());\n    name = name.replace('.', '/');\n    name += PROPS_SUFFIX;\n    Properties result = null;\n\n    // Returns null on lookup failures","sourceCodeStart":405,"sourceCodeEnd":441,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/StanfordCoreNLP.java#L405-L441","documentation":"loadPropertiesOrException loads a properties file by its name prefix from the classpath and throws a RuntimeIOException if no resource matching that prefix was found. Unlike error 831, this names the specific prefix that was searched.","triggerScenarios":"Calling new StanfordCoreNLP(propsFileNamePrefix) (String constructor) where no classpath resource exists matching the given prefix, e.g. new StanfordCoreNLP(\"StanfordCoreNLP-chinese\") without that resource bundled.","commonSituations":"Typos in the properties file name; using a language-specific default (e.g. StanfordCoreNLP-arabic) whose resource jar (models) is not on the classpath; file present on disk but not on the classpath.","solutions":["Check the exact prefix spelling and ensure a matching .properties resource exists on the classpath.","Add the corresponding resource/model jar (e.g. stanford-corenlp-X-models, or the language-specific properties) to the classpath.","Load the file from a filesystem path into a Properties object yourself and use the Properties constructor.","If it must load, verify Thread.currentThread().getContextClassLoader() can see the resource (application-server classloader issues)."],"exampleFix":"// before\nStanfordCoreNLP pipeline = new StanfordCoreNLP(\"StanfordCoreNLP-chinese\"); // resource missing\n// after\nprops.load(new FileInputStream(\"conf/StanfordCoreNLP-chinese.properties\"));\nStanfordCoreNLP pipeline = new StanfordCoreNLP(props);","handlingStrategy":"validation","validationCode":"String res = prefix.endsWith(\".properties\") ? prefix : prefix + \".properties\";\nif (Thread.currentThread().getContextClassLoader().getResource(res) == null) {\n  throw new IllegalStateException(\"Properties resource not on classpath: \" + res);\n}","typeGuard":null,"tryCatchPattern":"try { pipeline = new StanfordCoreNLP(prefix); } catch (RuntimeIOException e) { log.error(\"Missing properties file for prefix {}: {}\", prefix, e.getMessage()); throw e; }","preventionTips":["Keep properties file names exactly matching the prefix passed to the constructor.","Add language model jars (e.g. stanford-corenlp-models) to the classpath before using language defaults.","Test resource visibility with ClassLoader.getResource in unit tests."],"tags":["java","classpath","properties-file","resource-not-found"],"backgroundTag":"config-file-not-found","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}