Trying to connect to JanusGraph server/Cassandra with Kotlin client

I'm new to JanusGraph and attempting to connect to a remote server from a Kotlin client. I have created two Docker containers and everything looks good from the logs of JanusGraph:
docker run -d -p 7000:7000 -p 7001:7001 -p 7199:7199 -p 9042:9042 -p 9160:9160 -e CASSANDRA_START_RPC=true cassandra:4.0.6
docker run -d -p 7000:7000 -p 7001:7001 -p 7199:7199 -p 9042:9042 -p 9160:9160 -e CASSANDRA_START_RPC=true cassandra:4.0.6
docker run -d -p 8182:8182 -p 8184:8184 -e JANUS_PROPS_TEMPLATE=cql -e janusgraph.storage.hostname=host.docker.internal janusgraph/janusgraph:1.0.0
docker run -d -p 8182:8182 -p 8184:8184 -e JANUS_PROPS_TEMPLATE=cql -e janusgraph.storage.hostname=host.docker.internal janusgraph/janusgraph:1.0.0
I'm following the Connecting from Java directions with both conf/remote-graph.properties and conf/remote-objects.yaml available. In my Kotlin client, I'm just running:
val g = traversal().withRemote("conf/remote-graph.properties")
g.addV("person").property("name", "john").next()
val g = traversal().withRemote("conf/remote-graph.properties")
g.addV("person").property("name", "john").next()
The error I get is:
java.lang.UnsupportedOperationException: Graph does not support adding vertices
at org.apache.tinkerpop.gremlin.structure.Graph$Exceptions.vertexAdditionsNotSupported(Graph.java:1248)
at org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph.addVertex(EmptyGraph.java:60)
at org.apache.tinkerpop.gremlin.structure.Graph.addVertex(Graph.java:128)
java.lang.UnsupportedOperationException: Graph does not support adding vertices
at org.apache.tinkerpop.gremlin.structure.Graph$Exceptions.vertexAdditionsNotSupported(Graph.java:1248)
at org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph.addVertex(EmptyGraph.java:60)
at org.apache.tinkerpop.gremlin.structure.Graph.addVertex(Graph.java:128)
I've seen other questions out there that involve adding snippets to the server yaml and/or groovy scripts but I'm not sure what is necessary. I'm trying to keep this as simple as possible to start. Appreciate any tips!
1 Reply
barrettc
barrettcOP4mo ago
I'm getting closer I think. I'm able to add a vertex using the following snippet that I found in a Stackoverflow answer.
val g = traversal().withRemote("janusgraph/conf/remote-graph.properties")
val tx = g.tx()
tx.open()
g.addV("tacos").property("name", "chicken").next()
val g = traversal().withRemote("janusgraph/conf/remote-graph.properties")
val tx = g.tx()
tx.open()
g.addV("tacos").property("name", "chicken").next()
However, what I really want to do is return g.graph so that I can use the org.apache.tinkerpop.gremlin.structure.Graph interface to be compatible with existing code in our project. When I try to modify the graph using the Graph instead of the GraphTraversalSource, I'm still seeing the error about not supporting addition of verticies.

Did you find this page helpful?