{"record":{"id":"031ad8d61c0ff130","repo":"stanfordnlp/CoreNLP","slug":"error-could-not-find-properties-file-in-the-class","errorCode":null,"errorMessage":"ERROR: Could not find properties file in the classpath!","messagePattern":"ERROR: Could not find properties file in the classpath!","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"src/edu/stanford/nlp/pipeline/StanfordCoreNLP.java","lineNumber":417,"sourceCode":"      printRequiredProperties(System.err);\n      throw new RuntimeException(\"Missing property: \\\"\" + name + '\\\"');\n    }\n    return val;\n  }\n\n  /**\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);","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/StanfordCoreNLP.java#L399-L435","documentation":"When no explicit properties file is supplied, StanfordCoreNLP tries to load 'StanfordCoreNLP' or 'edu.stanford.nlp.pipeline.StanfordCoreNLP' from the classpath. If neither resource exists it throws this RuntimeException, meaning default configuration could not be located.","triggerScenarios":"Calling new StanfordCoreNLP() (no-arg constructor) or StanfordCoreNLP.fromClassPath() when the classpath contains no StanfordCoreNLP.properties-style resource under either valid name.","commonSituations":"Running CoreNLP from a jar/build setup where the default properties file was not packaged; wrong working directory or classloader in embedded/app-server contexts; shading the jar and dropping resources.","solutions":["Pass a properties file explicitly: new StanfordCoreNLP(\"MyConfig.properties\") or new StanfordCoreNLP(props).","Place a file named StanfordCoreNLP.properties (or edu/stanford/nlp/pipeline/StanfordCoreNLP.properties) on the classpath.","Ensure the resource is included in your build (e.g. maven resources filtering/excludes) and use the correct classloader.","Call fromProperties/StanfordCoreNLP(Properties) variant instead of the classpath lookup."],"exampleFix":"// before\nStanfordCoreNLP pipeline = new StanfordCoreNLP(); // searches classpath, not found\n// after\nProperties props = new Properties();\nprops.setProperty(\"annotators\", \"tokenize,ssplit,pos\");\nStanfordCoreNLP pipeline = new StanfordCoreNLP(props);","handlingStrategy":"fallback","validationCode":"ClassLoader cl = Thread.currentThread().getContextClassLoader();\nif (cl.getResource(\"StanfordCoreNLP.properties\") == null &&\n    cl.getResource(\"edu/stanford/nlp/pipeline/StanfordCoreNLP.properties\") == null) {\n  log.warn(\"No default CoreNLP properties on classpath; supply Properties explicitly\");\n}","typeGuard":null,"tryCatchPattern":"try { pipeline = new StanfordCoreNLP(); } catch (RuntimeException e) { pipeline = new StanfordCoreNLP(loadFallbackProps()); }","preventionTips":["Ship a StanfordCoreNLP.properties in src/main/resources of your project.","Verify with jar tf that resources survived shading/assembly.","Prefer explicit Properties construction over implicit classpath defaults."],"tags":["java","classpath","configuration","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"}