I'm trying to create DB and env using LMDB. I'm facing an issue on Env. create(). I have used LMDB documentation for this.
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.lmdbjava.ByteBufferProxy.<clinit>(ByteBufferProxy.java:71)
at org.lmdbjava.Env.create(Env.java:92)
at Database.<init>(Database.java:23)
at Index.main(Index.java:7)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field long java.nio.Buffer.address accessible: module java.base does not "opens java.nio" to unnamed module @4edde6e5
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:177)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:171)
at org.lmdbjava.ByteBufferProxy$AbstractByteBufferProxy.findField(ByteBufferProxy.java:163)
at org.lmdbjava.ByteBufferProxy$ReflectiveProxy.<clinit>(ByteBufferProxy.java:222)
... 4 more
Main:
public class Index {
public static void main(String[] args) {
Database db = new Database("./data", "DB.TEST");
}
}
public class Database {
private String dbName;
private String dbDirectoryName;
private File dbDirectory;
private Env<ByteBuffer> dbEnvironment;
private Dbi<ByteBuffer> db;
public Database(String _dbDirectoryName, String _dbName) {
dbName = _dbName;
dbDirectoryName = _dbDirectoryName;
dbDirectory = new File(dbDirectoryName);
dbEnvironment = Env.create().setMapSize(1_073_741_824).setMaxDbs(1).open(dbDirectory);
db = dbEnvironment.openDbi(dbName, MDB_CREATE);
}
public void Close() {
dbEnvironment.close();
}
}