janusgraph

ClassNotFoundException OptionsStrategy


When i connect to remote server and try to modify a graph i get java.lang.ClassNotFoundException: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/OptionsStrategy

I try search information about this exception. I think it happens because something conflict with version of janusgraph-core, gremlin-server and gremlin-driver

//pom file dependencies

<dependencies>
        <dependency>
            <groupId>org.janusgraph</groupId>
            <artifactId>janusgraph-core</artifactId>
            <version>0.3.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tinkerpop</groupId>
            <artifactId>gremlin-driver</artifactId>
            <version>3.4.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tinkerpop</groupId>
            <artifactId>gremlin-server</artifactId>
            <version>3.4.2</version>
        </dependency>
</dependencies>
//jgex-remote.properties file

gremlin.remote.remoteConnectionClass=org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection
gremlin.remote.driver.sourceName=g
gremlin.remote.driver.clusterFile=.../janus_connect_config.yaml

//janus_connect_config.yaml file

hosts: [xxx.xxx.xxx.xxx]
port: xxxx
serializer: {
  className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0,
  config: {
    ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry]
  }
}
// java code
public class App {
    public static void main(String[] args) throws ConfigurationException {
        if (args.length == 0) {
            throw new IllegalArgumentException("Input args must contains path to file with configuration");
        }

        String configFilePath = args[0];

        PropertiesConfiguration connectConfig = new PropertiesConfiguration(configFilePath);

        Cluster cluster = null;
        Client client = null;

        try {
            cluster = Cluster.open(connectConfig.getString("gremlin.remote.driver.clusterFile"));
            client = cluster.connect();

            Bindings b = Bindings.instance();
            GraphTraversalSource graph = EmptyGraph.instance()
                    .traversal()
                    .withRemote(connectConfig);

            Vertex evnyh = graph.addV(b.of("label", "man"))
                    .property("name", "Evnyh")
                    .property("family", "Evnyhovich")
                    .next();
            Vertex lalka = graph.addV(b.of("label", "man"))
                    .property("name", "Lalka")
                    .property("family", "Lalkovich")
                    .next();

            graph.V(b.of("outV", evnyh)).as("a")
                    .V(b.of("inV", lalka)).as("b")
                    .addE(b.of("label", "friend")).from("a")
                    .next();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (client != null) {
                try {
                    client.close();
                } catch (Exception e) {
                    // nothing to do, just close client
                }
            }

            if (cluster != null) {
                try {
                    cluster.close();
                } catch (Exception e) {
                    // nothing to do, just close cluster
                }
            }
        }
    }
}

Can somebody help resolve this problem?


Solution

  • You have a version mismatch. Note that JanusGraph 0.3.1 is bound to the TinkerPop 3.3.x line of code:

    https://github.com/JanusGraph/janusgraph/blob/v0.3.1/pom.xml#L72

    and OptionStrategy (and related functionality) was not added in TinkerPop until the 3.4.x line of code. JanusGraph therefore cannot process requests which use that sort of functionality.