OtterMind/Chat2DB · error · RuntimeException
file not exist
Error message
file not exist
What it means
RuntimeException 'file not exist' from createExcelConnection when opening an existing excel-import H2 store: it checks for '<filePath>.mv.db' and, with create=false, throws if that file is empty/missing.
Source
Thrown at chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/excel/DbExcelTableServiceImpl.java:149
try {
excelReader = EasyExcel.read(filePath).readDefaultReturn(ReadDefaultReturnEnum.ACTUAL_DATA).headRowNumber(0)
.registerReadListener(new ReadMetaListener(result, filePath, this)).build();
List<ReadSheet> sheets = excelReader.excelExecutor().sheetList();
excelReader.read(sheets);
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
if (excelReader != null) {
excelReader.close();
}
}
}
private Connection createExcelConnection(Long id, boolean create) {
String filePath = String.format(FILE_PATH, id);
if (!create && FileUtil.isEmpty(new File(filePath + ".mv.db"))) {
throw new RuntimeException("file not exist");
}
String jdbcUrl = "jdbc:h2:" + filePath;
Connection connection = null;
try {
Class.forName("org.h2.Driver");
connection = DriverManager.getConnection(jdbcUrl, null, null);
} catch (Exception e) {
throw new RuntimeException(e);
}
return connection;
}
private void analyzeExcelWithRole(String filePath, ExcelCheckResponse result, Connection connection) {
ExcelReader excelReader = null;
try {
Map<Integer, ExcelCheckResponse.Sheet> sheetMap = result.getSheetList().stream().collect(Collectors.toMap(ExcelCheckResponse.Sheet::getSheetNo, s -> s));
excelReader = EasyExcel.read(filePath).readDefaultReturn(ReadDefaultReturnEnum.ACTUAL_DATA)
.registerReadListener(new ReadHeaderListener(result, filePath, connection, this)).build();View on GitHub (pinned to 5ee1e990e7)
Solutions
- Verify the H2 file path pattern (FILE_PATH) resolves to a writable, existing directory and the .mv.db for the id is present.
- Re-run the excel import from the upload/analyze step so the store is recreated with create=true first.
- Ensure no external cleanup (cron, docker tmpfs) removes the import work directory mid-flow.
Defensive patterns
Strategy: validation
Validate before calling
java.io.File mv = new java.io.File(String.format(FILE_PATH, id) + ".mv.db");
if (!create && (!mv.exists() || mv.length() == 0)) throw new IllegalStateException("file not exist"); Prevention
- Run the analyze/create phase before reopening an excel import store.
- Use a persistent, writable directory for FILE_PATH.
- Guard against external cleanup of the import work directory.
When it happens
Trigger: A subsequent excel-import step requests the H2 connection for an import id whose on-disk mv.db file was deleted, never created, or is zero-length (FileUtil.isEmpty).
Common situations: Temp directory cleaned between import phases; previous import failed before the file was created; the FILE_PATH base directory is not writable so creation silently produced nothing; stale id reused after cleanup.
Related errors
- Failed to create table for excel import:
- Failed to insert excel import data:
- Error opening file '
- ai.attachment.fileNotFound
- ai.attachment.localParseFailed
AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14).
Data as JSON: /api/errors/4903b1195ea4e4c0.
Report an issue: GitHub.