Search code examples
javaneo4jgremlintinkerpop3gremlin-server

Configure neo4j for gremlin server


I was following the instructions here for configuring neo4j with gremlin-server.

However, when I was executing the command bin/gremlin-server.sh install org.apache.tinkerpop neo4j-gremlin 3.3.3, there was a problem of resolving the dependencies (I guess)

Installing dependency org.apache.tinkerpop neo4j-gremlin 3.3.3
[INFO] IndyInterface - Copying - /Users/cbd/Dev/Apps/apache-tinkerpop-gremlin-server-3.3.3/ext/neo4j-gremlin/plugin/neo4j-gremlin-3.3.3.jar
[INFO] DependencyGrabber$_copyTo_closure6 - Copying - /Users/cbd/Dev/Apps/apache-tinkerpop-gremlin-server-3.3.3/ext/neo4j-gremlin/plugin/neo4j-tinkerpop-api-0.1.jar
Could not install the dependency: java.lang.RuntimeException: Error grabbing Grapes -- [download failed: org.slf4j#slf4j-api;1.7.22!slf4j-api.jar]
java.lang.RuntimeException: java.lang.RuntimeException: Error grabbing Grapes -- [download failed: org.slf4j#slf4j-api;1.7.22!slf4j-api.jar]
    at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:236)
    at org.apache.tinkerpop.gremlin.groovy.util.DependencyGrabber.getAdditionalDependencies(DependencyGrabber.groovy:198)
    at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:236)
    at org.apache.tinkerpop.gremlin.groovy.util.DependencyGrabber.copyDependenciesToPath(DependencyGrabber.groovy:123)
    at org.apache.tinkerpop.gremlin.server.util.GremlinServerInstall.main(GremlinServerInstall.java:38)
Caused by: java.lang.RuntimeException: Error grabbing Grapes -- [download failed: org.slf4j#slf4j-api;1.7.22!slf4j-api.jar]
    at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:236)
    at groovy.grape.GrapeIvy.getDependencies(GrapeIvy.groovy:422)
    at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:236)
    at groovy.grape.GrapeIvy.resolve(GrapeIvy.groovy:569)
    at groovy.grape.GrapeIvy.resolve(GrapeIvy.groovy:532)
    at groovy.grape.Grape.resolve(Grape.java:202)
    at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:236)
    at org.apache.tinkerpop.gremlin.groovy.util.DependencyGrabber$_getAdditionalDependencies_closure8.doCall(DependencyGrabber.groovy:190)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
    at groovy.lang.Closure.call(Closure.java:418)
    at groovy.lang.Closure.call(Closure.java:434)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2125)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1980)
    at org.codehaus.groovy.runtime.dgm$160.doMethodInvoke(Unknown Source)
    at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:236)
    at org.apache.tinkerpop.gremlin.groovy.util.DependencyGrabber.getAdditionalDependencies(DependencyGrabber.groovy:185)
    ... 3 more

I have tried an alternative solution, by downloading manually the jar of neo4j-gremlin from maven central repository and put it to the ext folder with the same structure as other plug-ins. However, while trying to start the server, I got the following errors stack:

bin/gremlin-server.sh conf/gremlin-server-neo4j.yaml 
[INFO] GremlinServer - 
         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----

[INFO] GremlinServer - Configuring Gremlin Server from conf/gremlin-server-neo4j.yaml
[INFO] MetricManager - Configured Metrics ConsoleReporter configured with report interval=180000ms
[INFO] MetricManager - Configured Metrics CsvReporter configured with report interval=180000ms to fileName=/tmp/gremlin-server-metrics.csv
[INFO] MetricManager - Configured Metrics JmxReporter configured with domain= and agentId=
[INFO] MetricManager - Configured Metrics Slf4jReporter configured with interval=180000ms and loggerName=org.apache.tinkerpop.gremlin.server.Settings$Slf4jReporterMetrics
[ERROR] ServerGremlinExecutor - Could not invoke constructor on class org.apache.tinkerpop.gremlin.server.util.DefaultGraphManager (defined by the 'graphManager' setting) with one argument of class Settings
Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor.<init>(ServerGremlinExecutor.java:91)
    at org.apache.tinkerpop.gremlin.server.GremlinServer.<init>(GremlinServer.java:120)
    at org.apache.tinkerpop.gremlin.server.GremlinServer.<init>(GremlinServer.java:84)
    at org.apache.tinkerpop.gremlin.server.GremlinServer.main(GremlinServer.java:343)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor.<init>(ServerGremlinExecutor.java:80)
    ... 3 more
Caused by: java.lang.NoClassDefFoundError: org/neo4j/tinkerpop/api/Neo4jGraphAPI
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
    at java.lang.Class.getMethod0(Class.java:3018)
    at java.lang.Class.getMethod(Class.java:1784)
    at org.apache.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:78)
    at org.apache.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:70)
    at org.apache.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:104)
    at org.apache.tinkerpop.gremlin.server.util.DefaultGraphManager.lambda$new$0(DefaultGraphManager.java:57)
    at java.util.LinkedHashMap$LinkedEntrySet.forEach(LinkedHashMap.java:671)
    at org.apache.tinkerpop.gremlin.server.util.DefaultGraphManager.<init>(DefaultGraphManager.java:55)
    ... 8 more
Caused by: java.lang.ClassNotFoundException: org.neo4j.tinkerpop.api.Neo4jGraphAPI
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 19 more
[INFO] OpLoader - Adding the standard OpProcessor.
[INFO] OpLoader - Adding the session OpProcessor.
[INFO] OpLoader - Adding the traversal OpProcessor.
[INFO] GremlinServer - Shutting down OpProcessor[]
[INFO] GremlinServer - Shutting down OpProcessor[session]
[INFO] GremlinServer - Shutting down OpProcessor[traversal]
[INFO] GremlinServer - Shutting down thread pools.
Exception in thread "gremlin-server-shutdown" java.lang.NullPointerException
    at org.apache.tinkerpop.gremlin.server.GremlinServer.stop(GremlinServer.java:253)
    at org.apache.tinkerpop.gremlin.server.GremlinServer.lambda$new$0(GremlinServer.java:101)
    at java.lang.Thread.run(Thread.java:748)

How do you configure successfully gremlin-server and neo4j?


Solution

  • Did you follow these steps in configuring Grape:

    http://tinkerpop.apache.org/docs/current/reference/#gremlin-applications

    I've also found that you may need to clear your .m2/ or .groovy/grapes directories if things still don't work quite right - for some reason that helps sometimes.

    downloading manually the jar of neo4j-gremlin from maven central repository

    That approach won't work unless you grab all of neo4j-gremlin's dependencies along with it.