{"record":{"id":"a0557037ec43ec42","repo":"stanfordnlp/CoreNLP","slug":"could-not-load-class-in-jar","errorCode":null,"errorMessage":"Could not load class in jar: ","messagePattern":"Could not load class in jar: ","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/edu/stanford/nlp/util/ArgumentParser.java","lineNumber":260,"sourceCode":"        // --Case: Jar\n        try (JarFile jar = new JarFile(f)) {\n          Enumeration<JarEntry> e = jar.entries();\n          while (e.hasMoreElements()) {\n            //(for each jar file element)\n            JarEntry jarEntry = e.nextElement();\n            String clazz = jarEntry.getName();\n            if (clazz.matches(\".*class$\")) {\n              //(if it's a class)\n              clazz = clazz.substring(0, clazz.length() - 6)\n                  .replaceAll(\"/\", \".\");\n              //(add it)\n              try {\n                classes.add(\n                    Class.forName(clazz,\n                        false,\n                        ClassLoader.getSystemClassLoader()));\n              } catch (ClassNotFoundException ex) {\n                warn(\"Could not load class in jar: \" + f + \" at path: \" + clazz);\n              } catch (NoClassDefFoundError ex) {\n                debug(\"Could not scan class: \" + clazz + \" (in jar: \" + f + ')');\n              }\n            }\n          }\n        } catch (IOException e) {\n          warn(\"Could not open jar file: \" + f + \"(are you sure the file exists?)\");\n        }\n      } else {\n        //case: ignored jar\n      }\n    }\n\n    return classes.toArray(new Class<?>[classes.size()]);\n  }\n\n  /**\n   * Get all the declared fields of this class and all super classes.","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/util/ArgumentParser.java#L242-L278","documentation":"While scanning jars for classes with @Option annotations, getVisibleClasses() calls Class.forName() on each candidate class name. If the class cannot be found by the system class loader (ClassNotFoundException), it logs 'Could not load class in jar: <jar> at path: <class>' and skips it. Scanning continues; the class is just not considered.","triggerScenarios":"Invoking ArgumentParser fillOptions/bootstrapMap with a jar directory scan (e.g. 'properties' or class discovery mode) where a jar contains class entries whose names do not resolve against the system class loader - typically classes with external dependencies, multi-release jar entries, or non-class resources misnamed as .class.","commonSituations":"Pointing the scan at an arbitrary directory of jars; jars containing optional provider classes (JDBC drivers, service loaders) not on the classpath; old jars compiled against removed APIs.","solutions":["Add the jar containing the missing class to the system classpath","Ignore the warning if the skipped class has no @Option annotations you need","Remove broken/stale jars from the scanned directory","Enable debug logging to see which class names are skipped and why"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// pre-check a jar's entries resolve before scanning\ntry (JarFile jf = new JarFile(jarFile)) {\n    jf.stream().map(e -> e.getName())\n     .filter(n -> n.endsWith(\".class\"))\n     .forEach(n -> {\n         String cn = n.replace('/', '.').replaceAll(\"\\\\.class$\", \"\");\n         try { Class.forName(cn, false, ClassLoader.getSystemClassLoader()); }\n         catch (ClassNotFoundException ex) { /* will be skipped by parser */ }\n     });\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep only needed, intact jars in the scanned directory","Treat the warning as informational - skipped classes rarely matter for option parsing","Enable debug logging to audit skipped classes"],"tags":["java","classpath","jar-scanning","reflection"],"backgroundTag":"class-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"}