I'm trying to build a simple SNARL API example.
I'm following the " Java Programming" and "Using Maven" sections in the docs.
First of all, the updated examples (see for example here:
differ from the docs in that they say that I have to initialize the Stardog instance first, something that is missing in the docs so I have two versions of the code: one with the instance initialization (call that E1) and one without (call that E2).
Well, now by looking at "Using Maven" it's not clear what deps I need. This is not a server program, it's not an http-client program either, it's an embedded instance accessed via SNARL.
OK, I tried all the permutations of the 5 "client type dependencies" in the docs and E1 inevitably fails with a "No driver was found which supports the connection string: 'embed://system/' whereas E2 fails with a "java.lang.NoClassDefFoundError: org/quartz/SchedulerException".
But hey, look, under "Using Maven" there is a pointer: " You can see an example of their usage in our examples repository on Github", cool!
Not so fast, this is still a Gradle example and is way outdated.
So I switched to the develop version of the Gradle buildfile and I tried to reconstruct the same structure with Maven. The results looks like the following:
ok, lots of stuff that I do not need but I can try to trim them out later... build... run... same results as above.
OK, let's assume that Stardog.builder().create() is really needed and get rid of the java.lang.NoClassDefFoundError: org/quartz/SchedulerException by explicitly adding quartz to the deps...
Good we are making progress, not it complains about Caffeine: java.lang.NoClassDefFoundError: com/github/benmanes/caffeine/cache/Caffeine.
And if I add Caffeine to the deps I get Error in custom provider, java.lang.RuntimeException: Could not load system index: system.
OK, going nowhere.
Now the questions are:
is Stardog.builder().create() needed? If so please update the docs, if it is not please update the examples.
can you please provide me a minimal set of Maven deps to run a simple SNARL API program with an embedded server (and maybe update/improve the Maven docs since you are at that)?
The docs are indeed not explicit about this, however the Stardog.builder().create() call is needed if you intend to start up the embedded server, as it seems you want to do. I should note that this is the new and improved way to do this as of Stardog 6, which could explain the slight disconnect. The docs section does seem to go off the assumption that you are connecting to the embedded server, so perhaps it should be more explicit about this, however if you were running a local instance of the Stardog server you would NOT need this call, as you could just point the AdminConnectionConfiguration to that instance instead.
Because you want to run the embedded server, you actually do need the server dependency. You're technically correct about it not being an HTTP client but rather an embedded one, and we do actually have a client-embedded artifact, but client-http brings that (as well as everything else) in along with it.
I was able to get the exact main method from the stardog-examples repository to which you linked by bringing in just server and client-http as follows:
Thanks Steph, it turned out that I had a broken quartz jar in my .m2 and since I was running the application from within Eclipse I got no error notifications.
When I tried a maven install I saw the problem.
A build system whose usual fix is "clean the local repo" is a mess indeed...
However: now I can build the app and run in from the produced jar but I'm still having troubles with running it from Eclipse: the error I get is this:
There was an error initializing Stardog; one or more dependencies could not be satisfied. Please verify your classpath is correct.
The initialization errors were:
* Error in custom provider, java.lang.RuntimeException: Could not load system index: system
it is probably a problem with the Maven Eclipse plugin but maybe I can try to fix it by manually adding some missing deps if you could just point me in the right direction...
It's been a while since anyone here has used Eclipse or the Maven Eclipse plugin, however this sounds like it could be a matter of $STARDOG_HOME being set incorrectly. Either that or since it's complaining about VirtualGraph things perhaps you have a virtual graph defined and Eclipse can't find the JDBC driver?