stanfordnlp/CoreNLP · warning
Could not open jar file:
Error message
Could not open jar file:
What it means
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.
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
Example fix
# before: scan dir contains truncated jar # after: verify and replace unzip -t mylib.jar || (rm mylib.jar && mvn dependency:copy -Dartifact=com.example:mylib:1.0)
Defensive patterns
Strategy: validation
Validate before calling
File f = new File(jarPath);
if (!f.isFile() || f.length() == 0) throw new IllegalArgumentException("Not a readable jar: " + f);
try (java.util.zip.ZipFile zf = new java.util.zip.ZipFile(f)) {
if (zf.size() == 0) throw new IllegalArgumentException("Empty/corrupt jar: " + f);
} catch (java.io.IOException e) {
throw new IllegalArgumentException("Corrupt jar: " + f, e);
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.
Related errors
- argsToProperties could not read properties file: " + file
- Cannot find or open + sentFileName
- Could not create directory <tgtDir.getAbsolutePath()>, as a…
- Could not create directory <tgtDir.getAbsolutePath()>
- Could not open temporary feature index file for reading.
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/f1045114a48955bc.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/util/ArgumentParser.java:267
if (clazz.matches(".*class$")) {
//(if it's a class)
clazz = clazz.substring(0, clazz.length() - 6)
.replaceAll("/", ".");
//(add it)
try {
classes.add(
Class.forName(clazz,
false,
ClassLoader.getSystemClassLoader()));
} catch (ClassNotFoundException ex) {
warn("Could not load class in jar: " + f + " at path: " + clazz);
} catch (NoClassDefFoundError ex) {
debug("Could not scan class: " + clazz + " (in jar: " + f + ')');
}
}
}
} catch (IOException e) {
warn("Could not open jar file: " + f + "(are you sure the file exists?)");
}
} else {
//case: ignored jar
}
}
return classes.toArray(new Class<?>[classes.size()]);
}
/**
* Get all the declared fields of this class and all super classes.
*/
private static Field[] scrapeFields(Class<?> clazz) throws Exception {
List<Field> fields = new ArrayList<>();
while (clazz != null && !clazz.equals(Object.class)) {
fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
clazz = clazz.getSuperclass();
}View on GitHub (pinned to 1b7edd19c4)