Error when creating a DB with geospatial data

Hi There,

I recently set up STARDOG (on windows :slight_smile: 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 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.( ~[stardog-spatial-core-5.0-beta.jar:?]
at ~[stardog-spatial-core-5.0-beta.jar:?]
at com.complexible.stardog.spatial.db.GeospatialConnectableFactory.create( ~[stardog-spatial-core-5.0-beta.jar:?]
at com.complexible.stardog.db.DatabaseImpl.createConnectables( ~[stardog-5.0-beta.jar:?]
at com.complexible.stardog.db.DatabaseImpl.initializeConnectables( ~[stardog-5.0-beta.jar:?]
at com.complexible.stardog.db.DatabaseImpl.initializeConnectables( ~[stardog-5.0-beta.jar:?]
at com.complexible.stardog.db.DatabaseImpl.initialize( ~[stardog-5.0-beta.jar:?]
at com.complexible.stardog.StardogKernel.createDatabase( ~[stardog-5.0-beta.jar:?]
at com.complexible.stardog.StardogKernel.createDatabase( ~[stardog-5.0-beta.jar:?]
at com.complexible.stardog.protocols.http.server.AdminDatabaseService.createNewDatabase( ~[stardog-protocols-http-server-5.0-beta.jar:?]
at com.stardog.http.server.undertow.jaxrs.ExtractRoutes.lambda$handleIt$81( ~[stardog-protocols-http-server-5.0-beta.jar:?]
at ~[shiro-core-1.2.3.jar:1.2.3]
at ~[shiro-core-1.2.3.jar:1.2.3]
at com.stardog.http.server.undertow.ErrorHandling.lambda$safeDispatch$43( ~[stardog-protocols-http-server-5.0-beta.jar:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker( [?:1.8.0_111]
at java.util.concurrent.ThreadPoolExecutor$ [?:1.8.0_111]
at [?:1.8.0_111]
Caused by: java.lang.ClassNotFoundException: com.vividsolutions.jts.geom.Geometry
at ~[?:1.8.0_111]
at java.lang.ClassLoader.loadClass( ~[?:1.8.0_111]
at sun.misc.Launcher$AppClassLoader.loadClass( ~[?:1.8.0_111]
at java.lang.ClassLoader.loadClass( ~[?: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 :slight_smile:

Where did you put your 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

What exact version of jts did you grab? I believe you should be using jts-core-1.14.0.jar but I've never had that officially confirmed. You can grab the jar out of maven central

I mentioned the JTS version because the vividsolutions website was not being updated and listed an old version but it looks like JTS has found a new sponsor and is being hosted at github under a new license.

JTS is open source software. It is dual-licensed under:

Eclipse Public License 1.0
Eclipse Distribution License 1.0 (a BSD Style License)

I’m not familiar with wth Eclipse Distribution License but hopefully being a BSD Style license might mean it can be included with Stardog

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.


Hi Stephen,

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! :slight_smile:

Thanks a lot,


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!

Kind regards,


1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.