I recently set up STARDOG (on windows and I am attempting to upload two RDF graphs with geospatial data. I follow the instructions (and also those provided by Stephen Nowell on stackoverflow) as follows.
I downloaded the developer edition. I created a stardog.properties file and set spatial.use.jts=true. I saved JTS JAR in several folders (home, server, and servers three subfolders) as it is still not clear to me which folder is the classpath and hence where I need to have the JAR.
I then started a stardog server, and ran the following command: stardog-admin db create -n myDb x.ttl y.ttl -o spatial.enabled=true โ
I then get the following line in the command line: com/vividsolutions/jts/geom/Geometry
And the following error in the log:
java.lang.NoClassDefFoundError: com/vividsolutions/jts/geom/Geometry
at com.complexible.stardog.spatial.impl.LuceneGeospatialIndex.(LuceneGeospatialIndex.java:65) ~[stardog-spatial-core-5.0-beta.jar:?]
at com.complexible.stardog.spatial.impl.LuceneGeospatialIndexFactory.open(LuceneGeospatialIndexFactory.java:59) ~[stardog-spatial-core-5.0-beta.jar:?]
at com.complexible.stardog.spatial.db.GeospatialConnectableFactory.create(GeospatialConnectableFactory.java:77) ~[stardog-spatial-core-5.0-beta.jar:?]
at com.complexible.stardog.db.DatabaseImpl.createConnectables(DatabaseImpl.java:308) ~[stardog-5.0-beta.jar:?]
at com.complexible.stardog.db.DatabaseImpl.initializeConnectables(DatabaseImpl.java:468) ~[stardog-5.0-beta.jar:?]
at com.complexible.stardog.db.DatabaseImpl.initializeConnectables(DatabaseImpl.java:464) ~[stardog-5.0-beta.jar:?]
at com.complexible.stardog.db.DatabaseImpl.initialize(DatabaseImpl.java:745) ~[stardog-5.0-beta.jar:?]
at com.complexible.stardog.StardogKernel.createDatabase(StardogKernel.java:2389) ~[stardog-5.0-beta.jar:?]
at com.complexible.stardog.StardogKernel.createDatabase(StardogKernel.java:1267) ~[stardog-5.0-beta.jar:?]
at com.complexible.stardog.protocols.http.server.AdminDatabaseService.createNewDatabase(AdminDatabaseService.java:432) ~[stardog-protocols-http-server-5.0-beta.jar:?]
at com.stardog.http.server.undertow.jaxrs.ExtractRoutes.lambda$handleIt$81(ExtractRoutes.java:183) ~[stardog-protocols-http-server-5.0-beta.jar:?]
at org.apache.shiro.subject.support.SubjectRunnable.doRun(SubjectRunnable.java:120) ~[shiro-core-1.2.3.jar:1.2.3]
at org.apache.shiro.subject.support.SubjectRunnable.run(SubjectRunnable.java:108) ~[shiro-core-1.2.3.jar:1.2.3]
at com.stardog.http.server.undertow.ErrorHandling.lambda$safeDispatch$43(ErrorHandling.java:70) ~[stardog-protocols-http-server-5.0-beta.jar:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_111]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_111]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_111]
Caused by: java.lang.ClassNotFoundException: com.vividsolutions.jts.geom.Geometry
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[?:1.8.0_111]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_111]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[?:1.8.0_111]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_111]
โฆ 17 more
It looks like the ordering on your CLI command is a little bit off. The input files need to be the last things passed in. Try stardog-admin db create -n myDb -o spatial.enabled=true -- x.ttl y.ttl and see if that gives you anything different.
No worries. You've got the right dog, just the wrong doghouse
Where did you put your stardog.properties file? It should be located in the Stardog home directory (%STARDOG_HOME% in your case)
It seems like the most likely explanation is you haven't successfully gotten the jts jar in classpath. You can technically put it in any directory that is in the class path with would include any directory under %STARDOG_HOME%/server/ with the most logical on being %STARDOG_HOME%/server/dbms . If you want to keep third party jars separate from your installation you can also create the directory ext (%STARDOG_HOME%/server/ext) and put it in there.
The command you're using to create the database is a little mixed up. It should be
stardog-admin db create -n myDb -o spatial.enabled=true -- x.tty y.tty
I think I see why you were putting the jar in the server directory. The documentation has a line
To enable support for these more complex shapes, download JTS and include the JAR in Stardogโs server classpath.
I don't think that the server directory is actually included in the class path but all the directories contained in the server directory are included. That might require an update to the documentation.
This is correct. It should probably say server/ext, though any of the subfolders will be included on the classpath by default. Thanks for pointing this out.
Another thing missing in the documentation is that you can set the STARDOG_EXT environment variable to point to a directory that contains the external jar files. Using a fixed location outside Stardog installation directory makes it easier to upgrade to a new version without copying those jar files.
This actually fixed the problem. Sorry about the late reply, but I started indexing a large file yesterday and wanted to make sure it worked, and it is working!
Thanks for all these suggestions. While Stephens helped me fix the problem, I think for others who might hit the same issues, these comments should be helpful!