{"record":{"id":"f1045114a48955bc","repo":"stanfordnlp/CoreNLP","slug":"could-not-open-jar-file","errorCode":null,"errorMessage":"Could not open jar file: ","messagePattern":"Could not open jar file: ","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/edu/stanford/nlp/util/ArgumentParser.java","lineNumber":267,"sourceCode":"            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.\n   */\n  private static Field[] scrapeFields(Class<?> clazz) throws Exception {\n    List<Field> fields = new ArrayList<>();\n    while (clazz != null && !clazz.equals(Object.class)) {\n      fields.addAll(Arrays.asList(clazz.getDeclaredFields()));\n      clazz = clazz.getSuperclass();\n    }","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/util/ArgumentParser.java#L249-L285","documentation":"getVisibleClasses() opens each jar with a JarFile to enumerate entries. If the jar cannot be opened as a zip (IOException - missing, empty, or corrupt file, or a path that is not a jar), it logs 'Could not open jar file: <f> (are you sure the file exists?)' and moves on to the next jar. No classes from that jar are registered.","triggerScenarios":"Passing a directory to ArgumentParser class discovery where an entry is a zero-byte, truncated (interrupted download), corrupted, or non-zip file with a .jar extension, or a file deleted between listing and opening.","commonSituations":"Partially downloaded Maven jars; jars corrupted by filesystem issues or interrupted builds; directories containing placeholder/LFS pointer files instead of real jars; wrong directory passed to the scan.","solutions":["Verify the file exists and is a valid zip: `unzip -t <file>.jar` or `file <f>`","Re-download or rebuild the corrupted jar (e.g. `mvn dependency:purge-local-repository`)","Remove empty/placeholder files from the scanned jar directory","Check disk space and filesystem health if many jars fail at once"],"exampleFix":"# before: scan dir contains truncated jar\n# after: verify and replace\nunzip -t mylib.jar || (rm mylib.jar && mvn dependency:copy -Dartifact=com.example:mylib:1.0)","handlingStrategy":"validation","validationCode":"File f = new File(jarPath);\nif (!f.isFile() || f.length() == 0) throw new IllegalArgumentException(\"Not a readable jar: \" + f);\ntry (java.util.zip.ZipFile zf = new java.util.zip.ZipFile(f)) {\n    if (zf.size() == 0) throw new IllegalArgumentException(\"Empty/corrupt jar: \" + f);\n} catch (java.io.IOException e) {\n    throw new IllegalArgumentException(\"Corrupt jar: \" + f, e);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify jar integrity after download/build (unzip -t)","Exclude placeholder/LFS pointer files from scan directories","Watch disk space and handle build interruptions that truncate jars"],"tags":["java","jar","io","corrupt-file"],"backgroundTag":"file-open-failed","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}