Connecting to server from java: can't lock berkeleyje
queshaw
I'm trying to connect to janusgraph server from java. If I follow the instructions in the documentation, using this in gradle: implementation 'org.janusgraph:janusgraph-driver:0.6.2' implementation 'org.apache.tinkerpop:gremlin-driver:3.5.3' JanusGraph and JanusGraphFactory can't be found. If I add: implementation 'org.janusgraph:janusgraph-core:0.6.2' and I use conf/remote-graph.properties, I get an error message that root.storage.backend needs to be defined. I don't find that property, but if I add: storage.backend=berkeleyje then I get Could not find implementation class: org.janusgraph.diskstorage.berkeleyje.BerkeleyJEStoreManager If I add: implementation 'org.janusgraph:janusgraph-berkeleyje:0.6.2' then I get: Please supply configuration parameter "storage.directory" or both "storage.root" and "graph.graphname". If I add: storage.directory=/somewhere/graph/berkeleyje then I get: /somewhere/graph/berkeleyje The environment cannot be locked for single writer access. ENV_LOCKED: The je.lck file could not be locked. Environment is invalid and must be closed. I think that is because the server is running and the file is locked. How can I connect to a running server remotely from java, if I'm using berkeleyje? I've been able to connect to the server to run queries from python and from gremlin shell. Thanks. |
|
queshaw
I should probably add I intend to use import static org.janusgraph.core.attribute.Text.* for textContains etc. On Saturday, September 10, 2022 8:50 AM, queshaw <queshaw@...> wrote:
|
|
hadoopmarc@...
You can take a look at:
https://docs.janusgraph.org/interactions/connecting/java/ Apparently, you used JanusGraphFactory, which opens an embedded JanusGraph instance in the client. If you want to client to connect to a JanusGraph serrver, you use need the g = traversal().withRemote() syntax as shown in the link above. Best wishes, Marc |
|
queshaw
D'oh... So, after that, I get a NullPointerException: AnonymousTraversalSource<GraphTraversalSource> ats = traversal(); // not null if (new File(props).exists()) // path to conf/remote-graph.properties g = ats.withRemote(props); java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException at org.apache.tinkerpop.gremlin.process.remote.RemoteConnection.from(RemoteConnection.java:73) at org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.withRemote(AnonymousTraversalSource.java:76) at org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.withRemote(AnonymousTraversalSource.java:66) at lnf.graph.Queries.go(Queries.java:52) at lnf.graph.Queries.main(Queries.java:41) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.apache.tinkerpop.gremlin.process.remote.RemoteConnection.from(RemoteConnection.java:71) ... 4 more Caused by: java.lang.IllegalStateException: java.lang.NullPointerException at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection.<init>(DriverRemoteConnection.java:84) ... 9 more Caused by: java.lang.NullPointerException at org.apache.tinkerpop.gremlin.driver.Cluster.open(Cluster.java:255) at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection.<init>(DriverRemoteConnection.java:80) ... 9 more The server is running and I can connect from gremlin shell. On Sunday, September 11, 2022 5:03 AM, hadoopmarc@... wrote:
|
|
hadoopmarc@...
The stacktrace is not very helpful, unfortunately, but that is not your doing. The original example does not use an "ats" variable but instantiates g with a oneliner, but it hard to see why this could make a difference. Most likely, the code has trouble finding the conf/remote-objects.yaml file, referenced in the conf/remote-graph.properties file.
As an alternative to fiddling with your current code, you could take a look at: https://github.com/JanusGraph/janusgraph/tree/v0.6.2/janusgraph-examples/example-remotegraph Best wishes, Marc |
|
queshaw
Apparently it replaces the full path to the properties file with a relative path (conf/remote-graph.properties), which isn't found, of course. So, I've copied them and now I can connect. Thanks. On Sunday, September 11, 2022 1:20 PM, hadoopmarc@... wrote:
|
|