当我连接到远程服务器并尝试修改图形时,我得到java.lang.ClassNotFoundException:线程“ main”中的异常java.lang.NoClassDefFoundError:org / apache / tinkerpop / gremlin / process / traversal / strategy / decoration / OptionsStrategy
我尝试搜索有关此异常的信息。我认为发生这种情况是因为与janusgraph-core,gremlin-server和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
}
}
}
}
}
有人可以解决这个问题吗?
答案 0 :(得分:1)
您的版本不匹配。请注意,JanusGraph 0.3.1绑定到TinkerPop 3.3.x代码行:
https://github.com/JanusGraph/janusgraph/blob/v0.3.1/pom.xml#L72
直到3.4.x代码行,才在TinkerPop中添加了和OptionStrategy
(以及related functionality)。因此,JanusGraph无法处理使用这种功能的请求。