OtterMind/Chat2DB · error · RuntimeException
Error opening file '
Error message
Error opening file '
What it means
RuntimeException "Error opening file '<file>'" from XMLUtils.parseDocument when opening the given java.io.File as a FileInputStream raises an IOException — most commonly FileNotFoundException because the path does not exist or is unreadable.
Source
Thrown at chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/ncx/XMLUtils.java:32
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class XMLUtils {
public static Document parseDocument(String fileName) {
return parseDocument(new java.io.File(fileName));
}
public static Document parseDocument(java.io.File file) {
try (InputStream is = new FileInputStream(file)) {
return parseDocument(new InputSource(is));
} catch (IOException e) {
throw new RuntimeException("Error opening file '" + file + "'", e);
}
}
public static Document parseDocument(InputStream is) {
return parseDocument(new InputSource(is));
}
public static Document parseDocument(java.io.Reader is) {
return parseDocument(new InputSource(is));
}
public static Document parseDocument(InputSource source) {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);View on GitHub (pinned to 5ee1e990e7)
Solutions
- Confirm the file path exists and is a regular file (Files.isRegularFile) before parsing.
- Ensure the process user has read permission on the file.
- If the file is a transient upload, keep it on disk for the lifetime of the parse call.
Defensive patterns
Strategy: validation
Validate before calling
java.io.File f = new java.io.File(fileName);
if (!java.nio.file.Files.isRegularFile(f.toPath())) throw new RuntimeException("Error opening file '" + f + "'"); Type guard
boolean isOpenableXmlFile(java.io.File f) { return f != null && f.isFile() && f.canRead(); } Prevention
- Check Files.isRegularFile + canRead before parseDocument.
- Keep uploaded config files on disk for the parse lifetime.
- Run the server under a user with read access to import paths.
When it happens
Trigger: parseDocument(fileName/File) called with a non-existent, directory, or permission-denied path during NCX/DBP config import.
Common situations: Uploaded temp file already removed; wrong path resolution; file is a directory; read permission missing under the server user.
Related errors
- file not exist
- file.type.unsupported
- Error parsing XML document
- The baseURL is not valid!
- The baseURL is not valid!
AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14).
Data as JSON: /api/errors/f59a2f4ef14e07f4.
Report an issue: GitHub.