I am trying to use exist-db in my application, so to test embedding it, i followed the guide specified on the eXist-db webppage http://www.exist-db.org/exist/apps/doc/deployment.xml. For the code in question itself:
import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Collection;
import org.xmldb.api.base.Database;
import org.exist.xmldb.DatabaseInstanceManager;
public class TestDB {
public static void main(String args[]) throws Exception {
// initialize driver
Class cl = Class.forName("org.exist.xmldb.DatabaseImpl");
Database database = (Database)cl.newInstance();
database.setProperty("create-database", "true");
DatabaseManager.registerDatabase(database);
// try to read collection
Collection col =
DatabaseManager.getCollection("xmldb:exist:///db", "admin", "");
String resources[] = col.listResources();
System.out.println("Resources:");
for (int i = 0; i < resources.length; i++) {
System.out.println(resources[i]);
}
// shut down the database
DatabaseInstanceManager manager = (DatabaseInstanceManager)
col.getService("DatabaseInstanceManager", "1.0");
manager.shutdown();
}
}
Code itself can be found at the bottom of the webppage i provided.
This ended up getting stuck on the execution of DatabaseManager.getCollection("xmldb:exist:///db", "admin", "")
with the following output https://pastebin.com/b6Tf7K1L .
The VM options i chose were -Djava.endorsed.dirs=lib/endorsed -Dexist.initdb=true -Dexist.home=.
(using 2017.2.7 IntelliJ IDEA and Java 8).
This is the first time i am working with both exist-db and xml databases in general, and have can't figure out the solution. I have followed the "Embedding eXist in an Application" part of the guide in above provided link.