Search code examples
orientdb

Using OrientDB 3.0.0m1 java API with TinkerPop 3


I am attempting to issue Tinker Pop 3 [Orient-DB 3.0 snapshot] requests via the Java API. I am using OCommandGremlin as follows [should match 2 Vs]: >

OGremlinHelper.global().create();
OCommandRequest req  = graph.command(new OCommandGremlin("g.V().has('name', 'fast').both()"));
Iterable<Vertex> result2 = req.execute();

....

It seems to be looking for TinkerPop 2.x class com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine

I get the following error:

WARNING: $ANSI{green {db=demodb}} GREMLIN language not available (not in classpath)
Exception in thread "main" java.lang.NoClassDefFoundError: com/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine
    at com.orientechnologies.orient.graph.gremlin.OGremlinEngineThreadLocal.get(OGremlinEngineThreadLocal.java:61)
    at com.orientechnologies.orient.graph.gremlin.OGremlinHelper.getGremlinEngine(OGremlinHelper.java:165)
    at com.orientechnologies.orient.graph.gremlin.OGremlinHelper.execute(OGremlinHelper.java:83)
    at com.orientechnologies.orient.graph.gremlin.OGremlinHelper.execute(OGremlinHelper.java:75)
    at com.orientechnologies.orient.graph.gremlin.OCommandGremlinExecutor.execute(OCommandGremlinExecutor.java:59)
    at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.executeCommand(OAbstractPaginatedStorage.java:2480)
    at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.command(OAbstractPaginatedStorage.java:2425)
    at com.orientechnologies.orient.core.command.OCommandRequestTextAbstract.execute(OCommandRequestTextAbstract.java:68)
    at com.tinkerpop.blueprints.impls.orient.OrientGraphCommand.execute(OrientGraphCommand.java:49)
    at BasicGremlinDriver.main(BasicGremlinDriver.java:202)
Caused by: java.lang.ClassNotFoundException: com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine
    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)

My maven file is as follows:

<dependencies>
    <dependency>
        <groupId>com.orientechnologies</groupId>
        <artifactId>orientdb-graphdb</artifactId>
        <version>3.0.0m1</version>
    </dependency>
    <dependency>
        <groupId>com.orientechnologies</groupId>
        <artifactId>orientdb-spatial</artifactId>
        <version>3.0.0m1</version>
    </dependency>
    <dependency>
        <groupId>com.orientechnologies</groupId>
        <artifactId>orientdb-lucene</artifactId>
        <version>3.0.0m1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tinkerpop</groupId>
        <artifactId>gremlin-core</artifactId>
        <version>3.2.4</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tinkerpop</groupId>
        <artifactId>tinkergraph-gremlin</artifactId>
        <version>3.2.4</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tinkerpop</groupId>
        <artifactId>gremlin-groovy</artifactId>
        <version>3.2.4</version>
    </dependency>

....

I also set $/META-INF/services/javax.script.ScriptEngineFactory to org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngineFactory which is the Tinker Pop 3 version and I can find it on my class path.

Feedback appreciated.

Thanks

JGZ


Solution

  • If you want to play it Apache Gremlin, get rid of

    <dependency>
        <groupId>com.orientechnologies</groupId>
        <artifactId>orientdb-graphdb</artifactId>
        <version>3.0.0m1</version>
    </dependency>
    

    and add:

    <dependency>
        <groupId>com.orientechnologies</groupId>
        <artifactId>orientdb-gremlin</artifactId>
        <version>3.0.0m1</version>
    </dependency>
    

    Orientdb graph binds to ThinkerPop 2.6: it is for backward compatibility. The support for Apache Gremlin 3.x is provided by the new artifact. PAy attention to packages name, the new package is:

    org.apache.tinkerpop.gremlin.orientdb
    

    note that in 3.0 we provide a native multimodel API that allows to works with graph without additional modules:

    http://orientdb.com/docs/3.0.x/java/Java-MultiModel-API.html