sparql-gremlin and janusgraph

83 views
Skip to first unread message

nguyenm9

unread,
Dec 2, 2021, 4:53:28 PM12/2/21
to Gremlin-users
Hey folks, am pretty close to getting this to work but need some last mile help :-)

We're running apache atlas which writes to janusgraph.  I'd like to be able to run sparql against this JG.

I'm running gremlin-server which connects to jg using the sparql-gremlin 3.5.1 plugin
I then run gremlin-console and remote connect to the server and everything seems to work

I'm able to issue:

gremlin> gr = graph.traversal()
==>graphtraversalsource[standardjanusgraph[hbase:[127.0.0.1:2181]], standard]

gremlin> g = traversal(SparqlTraversalSource).withEmbedded(gr.getGraph())
==>sparqltraversalsource[standardjanusgraph[hbase:[127.0.0.1:2181]], standard]

but when I try to sparql, i get:

gremlin> g.sparql("""select * where {?s ?p ?o . }""")
org.apache.tinkerpop.gremlin.process.traversal.Traversal$Admin.isRoot()Z

Anyone able to get this to work?  Feels like I'm close so may be missing something.

TIA

Stephen Mallette

unread,
Dec 3, 2021, 6:31:16 AM12/3/21
to gremli...@googlegroups.com
Something about what you've written here isn't clear to me:

>  I'm running gremlin-server which connects to jg using the sparql-gremlin 3.5.1 plugin
> I then run gremlin-console and remote connect to the server and everything seems to work

Are you saying you installed sparql-gremlin in Gremlin Server and then you use 

gremlin> :remote connect ....

to connect to that server to issue these following commands to it:

gremlin> gr = graph.traversal()
==>graphtraversalsource[standardjanusgraph[hbase:[127.0.0.1:2181]], standard]

gremlin> g = traversal(SparqlTraversalSource).withEmbedded(gr.getGraph())
==>sparqltraversalsource[standardjanusgraph[hbase:[127.0.0.1:2181]], standard]

Also, is there anything more to that error? a stacktrace perhaps?



--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/834298b3-ceb3-45a0-a901-3b60732ab61an%40googlegroups.com.

nguyenm9

unread,
Dec 3, 2021, 6:46:37 AM12/3/21
to Gremlin-users
Hi, thanks for the response.  To answer your first question, yes, I installed sparql-gremlin on the server and used the console to connect to the server.  I am new to jg, gremlin, sparql-gremlin so followed the instructions here to setup the console, server, jg connections (https://wforget.github.io/2020/12/14/Gremlin-Server-Console-%E9%80%82%E9%85%8D-Atlas-JanusGraph/).  I then did this: https://stackoverflow.com/questions/68905209/does-sparql-gremlin-plugin-support-janusgraph to install sparql-gremlin on gremlin server and also had to futz with the config a bit to load the plugin on server side.

Regarding the stack trace on the failed traversal call, please see (this is from the console side):

gremlin> :remote connect tinkerpop.server conf/remote.yaml session
==>Configured localhost/127.0.0.1:8182-[1e449fa7-9c25-4490-8a2f-0c5198a9db81]
gremlin> :remote console
==>All scripts will now be sent to Gremlin Server - [localhost/127.0.0.1:8182]-[1e449fa7-9c25-4490-8a2f-0c5198a9db81] - type ':remote console' to return to local mode
gremlin> gr = graph.traversal()
==>graphtraversalsource[standardjanusgraph[hbase:[127.0.0.1:2181]], standard]
gremlin> g = traversal(SparqlTraversalSource).withEmbedded(gr.getGraph())
==>sparqltraversalsource[standardjanusgraph[hbase:[127.0.0.1:2181]], standard]
gremlin> g.sparql("""select * where {?s ?p ?o .}""")
org.apache.tinkerpop.gremlin.process.traversal.Traversal$Admin.isRoot()Z
Type ':help' or ':h' for help.
Display stack trace? [yN]y
java.lang.NoSuchMethodError: org.apache.tinkerpop.gremlin.process.traversal.Traversal$Admin.isRoot()Z
        at org.apache.tinkerpop.gremlin.sparql.process.traversal.strategy.SparqlStrategy.apply(SparqlStrategy.java:68)
        at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies.applyStrategies(DefaultTraversalStrategies.java:88)
        at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.applyStrategies(DefaultTraversal.java:124)
        at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:195)
        at org.apache.tinkerpop.gremlin.server.op.AbstractOpProcessor.handleIterator(AbstractOpProcessor.java:97)
        at org.apache.tinkerpop.gremlin.server.op.AbstractEvalOpProcessor.lambda$evalOpInternal$5(AbstractEvalOpProcessor.java:263)
        at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval$0(GremlinExecutor.java:283)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
gremlin>


Thanks!

Stephen Mallette

unread,
Dec 3, 2021, 6:58:55 AM12/3/21
to gremli...@googlegroups.com
Is it possible you have a mix of versions between sparql-gremlin and the TinkerPop dependencies in JanusGraph? The stacktrace implies that it can't find isRoot() which was added in 3.5.x. It's almost like you are using a JanusGraph version that depends on 3.4.x. Could that be the issue?

nguyenm9

unread,
Dec 3, 2021, 7:16:30 AM12/3/21
to Gremlin-users
Oh nice catch.  The link first link I sent on how to setup gremlin with JG does some symbolic links on the gremlin-server to point to atlas *.jars.

Apache Atlas 2.2 use JG 0.5.3 (https://github.com/JanusGraph/janusgraph/releases/tag/v0.5.3) which does use tinkerpop 3.4.6 where as latest JG uses 0.6.0 which does support tp 3.5.1.  

Thanks!

nguyenm9

unread,
Dec 3, 2021, 12:17:25 PM12/3/21
to Gremlin-users
This was indeed the problem.  The latest branch release of Atlas is using an old version of JG/Tinkerpop so had to recompile the atlas master and once the new jars were used, sparql-gremlin worked.  Thanks so much.
Reply all
Reply to author
Forward
0 new messages