{"record":{"id":"f59a2f4ef14e07f4","repo":"OtterMind/Chat2DB","slug":"error-opening-file","errorCode":null,"errorMessage":"Error opening file '","messagePattern":"Error opening file '","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/ncx/XMLUtils.java","lineNumber":32,"sourceCode":"import java.io.FileInputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.List;\n\n\npublic class XMLUtils {\n\n    public static Document parseDocument(String fileName) {\n        return parseDocument(new java.io.File(fileName));\n    }\n\n    public static Document parseDocument(java.io.File file) {\n        try (InputStream is = new FileInputStream(file)) {\n            return parseDocument(new InputSource(is));\n        } catch (IOException e) {\n            throw new RuntimeException(\"Error opening file '\" + file + \"'\", e);\n        }\n    }\n\n    public static Document parseDocument(InputStream is) {\n        return parseDocument(new InputSource(is));\n    }\n\n    public static Document parseDocument(java.io.Reader is) {\n        return parseDocument(new InputSource(is));\n    }\n\n    public static Document parseDocument(InputSource source) {\n        try {\n            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\n            dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);\n            dbf.setFeature(\"http://apache.org/xml/features/disallow-doctype-decl\", true);\n            dbf.setFeature(\"http://xml.org/sax/features/external-general-entities\", false);\n            dbf.setFeature(\"http://xml.org/sax/features/external-parameter-entities\", false);","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/ncx/XMLUtils.java#L14-L50","documentation":"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.","triggerScenarios":"parseDocument(fileName/File) called with a non-existent, directory, or permission-denied path during NCX/DBP config import.","commonSituations":"Uploaded temp file already removed; wrong path resolution; file is a directory; read permission missing under the server user.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"java.io.File f = new java.io.File(fileName);\nif (!java.nio.file.Files.isRegularFile(f.toPath())) throw new RuntimeException(\"Error opening file '\" + f + \"'\");","typeGuard":"boolean isOpenableXmlFile(java.io.File f) { return f != null && f.isFile() && f.canRead(); }","tryCatchPattern":null,"preventionTips":["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."],"tags":["xml","filesystem","import","config"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}