NationalSecurityAgency/ghidra · error · SQLException
{}
Error message
{} What it means
Thrown by VectorStore.loadVectors() when H2FileFunctionDatabase.initialize() returns false. The exception message is the raw error from getLastError().message, which can be any database initialization failure: file not found, schema version mismatch, permission denied, or H2 engine error.
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/file/VectorStore.java:74
if (vectors == null) {
return EmptyIterator.INSTANCE;
}
return vectors.values().iterator();
}
public synchronized VectorStoreEntry getVectorById(long id) {
init();
if (vectors == null) {
return null;
}
return vectors.get(id);
}
private void loadVectors() throws SQLException {
// NOTE: assume file DB (see constructor above)
try (H2FileFunctionDatabase fnDb = new H2FileFunctionDatabase(serverInfo)) {
if (!fnDb.initialize()) {
throw new SQLException(fnDb.getLastError().message);
}
vectors = fnDb.readVectorMap();
}
}
public synchronized void invalidate() {
vectors = null;
}
public synchronized void update(VectorStoreEntry entry) {
if (vectors != null) {
vectors.put(entry.id(), entry);
}
}
public synchronized void update(long id, int count) {
if (vectors == null) {
return;View on GitHub (pinned to d5f144c24d)
Solutions
- Verify the database file path in serverInfo exists and is readable by the current process.
- Check for a stale lock file (*.lock.db) left by a crashed JVM and remove it if no process is using the database.
- Ensure the database was created or last migrated with a compatible Ghidra version; run any required schema migration.
- If initializing a fresh database, ensure H2FileFunctionDatabase.initialize() prerequisites (correct serverInfo, valid temp directory) are met.
Example fix
// before: VectorStore silently fails to load, throwing a vague error
try {
VectorStore store = new VectorStore(serverInfo);
store.getVectorById(42); // triggers lazy load, may throw
} catch (SQLException e) {
// message is opaque: just the DB's last error text
}
// after: validate the DB file exists and is accessible before loading
Path dbPath = Paths.get(serverInfo.getDatabaseFilePath());
if (!Files.exists(dbPath)) {
throw new IOException("BSim database file not found: " + dbPath);
}
VectorStore store = new VectorStore(serverInfo);
store.getVectorById(42); Defensive patterns
Strategy: validation
Validate before calling
Path dbFile = Paths.get(serverInfo.getDatabaseFilePath());
if (!Files.exists(dbFile)) {
throw new FileNotFoundException("BSim database file not found: " + dbFile);
}
if (!Files.isReadable(dbFile)) {
throw new IOException("BSim database file is not readable: " + dbFile);
}
// Check for stale lock
Path lockFile = dbFile.resolveSibling(dbFile.getFileName() + ".lock.db");
if (Files.exists(lockFile) && !isJvmAlive(lockFile)) {
Files.delete(lockFile);
}
VectorStore store = new VectorStore(serverInfo); Try / catch
try {
store.getVectorById(id);
} catch (SQLException e) {
// e.getMessage() is the raw error from H2FileFunctionDatabase.initialize()
// Log the underlying cause for diagnostics
log.error("Failed to load BSim vectors from {}", serverInfo, e);
throw new BSimInitializationException("Cannot open BSim database: " + e.getMessage(), e);
} Prevention
- Verify the database file exists and is readable before creating a VectorStore.
- Remove stale .lock.db files from crashed JVM processes before opening.
- Ensure the Ghidra version matches the one that created the BSim database to avoid schema mismatch.
When it happens
Trigger: The H2 database file referenced by the BSim serverInfo does not exist, is not readable, has an incompatible schema version, or is locked by another process. Called lazily from VectorStore.init() which is triggered by the first getVectorById(), update(), or similar access.
Common situations: Pointing BSim at a database file path that doesn't exist or has wrong permissions; upgrading Ghidra without migrating the BSim database schema; the H2 file is still locked by a previous JVM process that crashed.
Related errors
- Unknown vector hash
- Could not create database:
- Could not create database:
- database in use
- attempted to drop non-BSim database
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/70792eada24c90ca.
Report an issue: GitHub.