2

I'm trying to figure out how to connect to JanusGraph server from SpringBoot.

JanusGraph was setup with Cassandra and ElasticSearch to run in docker and as each instance of JanusGraph only serves one graph, I've updated gremlin-server.yaml to use ConfiguredGraphFactory so that it can dynamically add graphs on the server, following this guide https://jointhegraph.github.io/articles/hosting-multiple-graphs-on-janusgraph/.

graphManager: org.janusgraph.graphdb.management.JanusGraphManager
  graphs: {
    ConfigurationManagementGraph: conf/janusgraph-hbase-configurationgraph.properties
  }

The setup has been tested to be working with Gremlin-console and graphs are being created and persisted to Cassandra.

What I couldn't figure out is how to connect from SpringBoot app. I've tried using ConfiguredGraphFactory directly

graph = ConfiguredGraphFactory.getGraphNames().contains(xxx)
        ? ConfiguredGraphFactory.open(xxx)
        : ConfiguredGraphFactory.create(xxx);
    g = graph.traversal();

but it fails to connect to the JanusGraph server with the following error

java.lang.RuntimeException: org.janusgraph.graphdb.management.utils.ConfigurationManagementGraphNotEnabledException: Please add a key named "ConfigurationManagementGraph" to the "graphs" property in your YAML file and restart the server to be able to use the functionality of the ConfigurationManagementGraph class.

My guess is that the hostname/ip and port for JanusGraph server hasn't been specified but where and how can I set them using the JanusGraph classes?

I've checked the following but am still not getting it.

Would anyone be able to help?

Appreciate and many thanks.

毛三王
  • 41
  • 3
  • I've managed to get this working using Cluster to connect to the JanusGraph server and submitting the `ConfiguredGraphFactory.create(graphName)` as a command string via the client to create the graph dynamically. A traversal object can then be obtained with `traversal.withRemote(DriverRemoteConnection.using(host, port, traversalName));` where the traversal name is graphName_traversal. – 毛三王 Mar 27 '23 at 05:59
  • Did you write conf/janusgraph-hbase-configurationgraph.properties by yourself? Or should this be in the container by default? Because I dont have such – Zonko Jun 14 '23 at 10:33

0 Answers0