Use tinkerpop/gremlin with embedded database

I am looking for a way to use the tinkerpop/gremlin driver with an embedded orientdb.

I first start the server with OServerMain.create() and then open the DB using server.openDatabase(), which returns an instance of ODatabaseDocumentInternal. How can I (re-)use this instance to open a new OrientGraph instance? Or is there another way to connect to the embedded db?

I am using 3.0.18


Ok after 1 day of searching through the whole web and putting all puzzle pieces together I finally found a solution:

OServer server = OServerMain.create();
OrientDB db = server.getContext(); // re-use the existing db context 
factory = new OrientGraphFactory(db, dbName, ODatabaseType.PLOCAL, "admin", "admin").setupPool(1,10); // important user/pw MUST be admin/admin with plocal, even though your created db has other credentials


The only problem is now that when I create a schema of my database like this:

ODatabaseDocumentInternal database = server.openDatabase(dbName, "admin", "admin");
                // import schema
                ODatabaseImport dbImport = new ODatabaseImport(database, "config/schema.gz", listener);

and restart the app/db, the new OrientGraphFactory(..) fails with:

com.orientechnologies.orient.core.exception.OSecurityAccessException: User or password not valid for database: 'XX'
	DB name="XX"

It seems that the import bricks the db somehow. Any ideas?