Setup and Configuration of SPARQL-Gremlin plugin (with ArcadeDB)

Dear All, I would like to use the SPARQL-Gremlin ( https://tinkerpop.apache.org/docs/current/reference/#sparql-gremlin ) plugin with the embedded Gremlin server in ArcadeDB. ArcadeDB exposes the gremlin-server.groovy, gremlin-server.properties, and gremlin-server.yaml files in its config directory. So my questions are: 1. How do I install the plugin? Particularly, is there a way without recompiling the embedding ArcadeDB? 2. What configurations do I have to add to these files to activate and use the SPARQL plugin? I found some hints and partial examples here and there but patchworking those did not work. Thank you very much for your help
18 Replies
spmallette
spmallette2y ago
I'm not sure what @arcadedb allows with its embedded Gremlin Server but you would normally need to do two things with a standalone Gremlin Server: 1. get the sparql-gremlin in Gremlin Server's classpath with bin/gremlin-server.sh install org.apache.tinkerpop sparql-gremlin <version> which will install not only sparql-gremlin but all its dependencies. if that shell script isn't available with ArcadeDB, i guess you would have to get all those dependencies on the ArcadeDB classpath manually. maybe a shortcut way to do that would be to install sparql-gremlin in the Gremlin console then pull the jars from the {CONSOLE_HOME}/ext/sparql-gremlin directory 2. Add an entry like this to the Gremlin Server yaml file: https://github.com/apache/tinkerpop/blob/3.6.2/gremlin-server/conf/gremlin-server-spark.yaml#L50 but reference org.apache.tinkerpop.gremlin.sparql.jsr223.SparqlGremlinPlugin
GitHub
tinkerpop/gremlin-server-spark.yaml at 3.6.2 · apache/tinkerpop
Apache TinkerPop - a graph computing framework. Contribute to apache/tinkerpop development by creating an account on GitHub.
gramian
gramianOP2y ago
Hi @spmallette , Thank you for your reply. I performed the two steps you suggested (I manually copied all the jars below ext/sparql-gremlin to the folder holding ArcadeDB's jars), but I get, when using g.sparql("""SELECT * WHERE { ?x ?y ?z . }"""), the error No signature of method: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource.sparql(). Also when running graph = TinkerFactory.createModern() I get the error No such property: TinkerFactory for class: Script5.
spmallette
spmallette2y ago
did you configure g to in the Gremlin Server initialization script to use sparql-gremlin? your script should configure g like: g = traversal(SparqlTraversalSource) (i have no idea if ArcadeDB allows you to use the init script)
gramian
gramianOP2y ago
Running g = traversal(SparqlTraversalSource) results in the error: No such property: SparqlTraversalSource for class: Script8. About the init script, I can't say either.
spmallette
spmallette2y ago
that seems to indicate to me that either (step 2) isn't setup right or the jars aren't on the classpath somehow. not sure how ArcadeDB loads jars for this embedding, so maybe it's not as simple as just putting them in ArcadeDB's /lib folder (or equivalent). do Gremlin Server's logs show on startup? any errors?
gramian
gramianOP2y ago
This could be the case. The logs just state: GremlinServer plugin started Thank you nonetheless, this is a good foundation to start experimenting more. I will come back with further questions if necessary.
gramian
gramianOP2y ago
Hi, I have two follow up questions: 1. Which subfolder jars of ext/sparql-gremlin do I need to copy: lib or plugin? I copied both but there seem to be duplicates. 2. I get now the log output with the above suggested config in the gremlin-server.yaml:
Exception in thread "main" com.arcadedb.server.ServerException: Error on loading plugin org.apache.tinkerpop.gremlin.sparql.jsr223.SparqlGremlinPlugin
at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.initializeGremlinScriptEngineManager(GremlinExecutor.java:454)
at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.<init>(GremlinExecutor.java:110)
at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.<init>(GremlinExecutor.java:79)
at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor$Builder.create(GremlinExecutor.java:607)
at org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor.<init>(ServerGremlinExecutor.java:137)
at org.apache.tinkerpop.gremlin.server.GremlinServer.<init>(GremlinServer.java:127)
at org.apache.tinkerpop.gremlin.server.GremlinServer.<init>(GremlinServer.java:90)
at com.arcadedb.server.gremlin.GremlinServerPlugin.startService(GremlinServerPlugin.java:85)
at com.arcadedb.server.ArcadeDBServer.registerPlugins(ArcadeDBServer.java:209)
... 2 more
Caused by: java.lang.ClassNotFoundException: org.apache.tinkerpop.gremlin.sparql.jsr223.SparqlGremlinPlugin
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.initializeGremlinScriptEngineManager(GremlinExecutor.java:417)
... 10 more
Exception in thread "main" com.arcadedb.server.ServerException: Error on loading plugin org.apache.tinkerpop.gremlin.sparql.jsr223.SparqlGremlinPlugin
at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.initializeGremlinScriptEngineManager(GremlinExecutor.java:454)
at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.<init>(GremlinExecutor.java:110)
at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.<init>(GremlinExecutor.java:79)
at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor$Builder.create(GremlinExecutor.java:607)
at org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor.<init>(ServerGremlinExecutor.java:137)
at org.apache.tinkerpop.gremlin.server.GremlinServer.<init>(GremlinServer.java:127)
at org.apache.tinkerpop.gremlin.server.GremlinServer.<init>(GremlinServer.java:90)
at com.arcadedb.server.gremlin.GremlinServerPlugin.startService(GremlinServerPlugin.java:85)
at com.arcadedb.server.ArcadeDBServer.registerPlugins(ArcadeDBServer.java:209)
... 2 more
Caused by: java.lang.ClassNotFoundException: org.apache.tinkerpop.gremlin.sparql.jsr223.SparqlGremlinPlugin
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.initializeGremlinScriptEngineManager(GremlinExecutor.java:417)
... 10 more
Thank you again!
spmallette
spmallette2y ago
if they are identical (and i suspect they are) it shouldn't matter which you copy. some plugins like spark have different uses/contents so it might matter in those cases. that error is really strange if you have the sparql-gremlin jar on arcadedb's classpath. i'm not sure why you would get that error except in the cases where it's not being found.
gramian
gramianOP2y ago
I had the same feeling, given the error java.lang.ClassNotFoundException: org.apache.tinkerpop.gremlin.sparql.jsr223.SparqlGremlinPlugin. The line to add to the gremlin-server.yaml being org.apache.tinkerpop.gremlin.sparql.jsr223.SparqlGremlinPlugin: {} is correct, right? Just using the plugin jars I got a step further. Cool!
spmallette
spmallette2y ago
i think the line is right, but that's not the only step. you have to bin/gremlin-server.sh install .... to get the dependencies into the Gremlin Server path normally. maybe the best thing to do would be to do that in a vanilla Gremlin Server and then copy/paste from the server's /ext directory to the ArcadeDB path
gramian
gramianOP2y ago
Now I get: (See attachment).
gramian
gramianOP2y ago
Maybe I am missing an import in the gremlin-server.groovy or a processor or serializer in the gremlin-server.yaml?
spmallette
spmallette2y ago
looks like "g" simply isn't isn't initialized properly. does your gremlin-server.groovy file include the SparqlTraversalSource in the setup of "g"?
gramian
gramianOP2y ago
It has globals << [g : traversal(SparqlTraversalSource)]
spmallette
spmallette2y ago
hmm - that's not bound to a Graph instance though. like, i'd expect it to be like:
g = traversal(SparqlTraversalSource).withEmbedded(graph)
g = traversal(SparqlTraversalSource).withEmbedded(graph)
where "graph" is a graph name in your yaml file. that said, a bit odd that you got a parsing error with that. i'd have expected something else otoh, i'm not sure how ArcadeDB handles the embedded Gremlin Server it has
gramian
gramianOP2y ago
Can you explain what you mean with "where "graph" is a graph name in your yaml file." in more detail? Thank you for your patience
spmallette
spmallette2y ago
well, if you just do: g = traversal(SparqlTraversalSource) it doesn't bind "g" to a Graph instance. it just create a SparqlTraversalSource with an EmptyGraph which holds nothing. just like any construction of "g" you need to actually bind the traversal source to a graph, like, in Gremlin Console you would do:
graph = TinkerGraph.open();
g = traversal().withEmbedded(graph)
graph = TinkerGraph.open();
g = traversal().withEmbedded(graph)
you have to do the same thing in Gremlin Server. Gremlin Server configures Graph instances you can give to withEmbedded() in the gremlin-server.yaml file as shown here: https://github.com/apache/tinkerpop/blob/master/gremlin-server/conf/gremlin-server-modern.yaml#L22 again, no idea how this applies to ArcadeDB, but that's why you'd do in a vanilla Gremlin Server.
gramian
gramianOP2y ago
Thank you for this explanation.
Want results from more Discord servers?
Add your server