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 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

Hi,

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 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

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 http://search.maven.org/remotecontent?filepath=com/vividsolutions/jts-core/1.14.0/jts-core-1.14.0.jar

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 GitHub - locationtech/jts: The JTS Topology Suite is a Java library for creating and manipulating vector geometry. 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.

Best,
Evren

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,

Kris.

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,

Kris.

1 Like

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