Cannot connect to neo4j database from gremlin console

1,202 views
Skip to first unread message

Guy Melançon

unread,
Mar 29, 2016, 9:54:44 AM3/29/16
to Gremlin-users
I've been looking around in this google-group as well as in other discussion forums, 've been browsing quite a few pages of javadocs but I just seem incapable of finding a solution to a simple (I guess) question.

I run gremlin from the console. I have the neo4j plugin installed. I am using apache-gremlin-console-3.1.1-incubating

I run a neo4j instance on localhost, connected to a database stored on my local disk. I am running Neo4j 2.3.1 on OS X.

---

I am able to trigger a connection to an empty directory thus creating a brand new neo4j db. (I have also tried the step by step instructions by Stephen Mallette)

gremlin> config = new BaseConfiguration()

==>org.apache.commons.configuration.BaseConfiguration@52b7b9a4

gremlin> config.setProperty(Neo4jGraph.CONFIG_DIRECTORY, "/.../neo4j_gremlin_test/")

==>null

gremlin> g = new Neo4jGraph(config)

==>neo4jgraph[EmbeddedGraphDatabase [/Users/melancon/Documents/Recherche/Proposals/PEPS Idex COMPTRASEC/neo4j_data/neo4j_gremlin_test]]

gremlin> g.addVertex()

==>v[0]


etc.


---

I am unable to bind gremlin with my database using the Neo4jGraph class -- which I assumed was the proper way to go.

gremlin> config = new BaseConfiguration()

==>org.apache.commons.configuration.BaseConfiguration@3af17be2

gremlin> config.setProperty(Neo4jGraph.CONFIG_DIRECTORY, "/.../existing_neo4j_db/")

==>null

gremlin> g = new Neo4jGraph(config)

Error starting org.neo4j.kernel.EmbeddedGraphDatabase, /Users/melancon/Documents/Recherche/Proposals/PEPS Idex COMPTRASEC/neo4j_data/neo4j_test


---

I cannot find a (even short) tutorial on what is a good way to go. I see tons of examples using a string apparently pointing at local directory to initiate a connection.

Any help on how to improve my skills on this is warmly welcome. I find it quite hard to find reliable information when browsing the web due to version differences, API changes and deprecated methods, etc.

Thanks!
Guy

Stephen Mallette

unread,
Mar 30, 2016, 2:38:34 PM3/30/16
to Gremlin-users
Those instructions in Stackoverflow are for TinkerPop 2.x. If you look at the Neo4j section of the reference docs for 3.1.1 you can see several ways of creating a graph instance:


Note that the preferred method for creating any TinkerPop compliant Graph is to use its static open() method which will take an Apache Configuration object:

gremlin> conf = new BaseConfiguration()
==>org.apache.commons.configuration.BaseConfiguration@2b6c35a6
gremlin> conf.setProperty(Neo4jGraph.CONFIG_DIRECTORY,'/tmp/neo4j')
==>null
gremlin> graph = Neo4jGraph.open(conf)
==>neo4jgraph[org.neo4j.tinkerpop.api.impl.Neo4jGraphAPIImpl@2bdeb866]

I'm not sure what you mean by this:

I run a neo4j instance on localhost,

But Neo4jGraph is designed to run Neo4j in embedded mode, so if you are using starting Neo4j Server, I have a feeling that's part of your problem. You don't have all of your error message there, so i'm not sure if that's the cause, but it might be related.  The only way to run Neo4j Server and open a Neo4jGraph instance at the same time would be configure Neo4jGraph with HA (and while the capability is there to do that, I dont' think we've adequately tested it yet:







--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/1463cb0c-0dd3-444d-b048-e192fefa6caa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Guy Melançon

unread,
Mar 30, 2016, 4:40:58 PM3/30/16
to Gremlin-users
Thanks Stephen for educating me with gremlin and TinkerPop,

I see my problem stems from my ignorance on what is meant by "running Neo4j in embedded mode". To be honest, I expected gremlin to connect to Neo4j just as one usually connects to a database driver, providing credentials to first connect with the db server. This is obviously wrong, and probably at the source of my misunderstanding and difficulties.

I had already looked at the TinkerPop documentation you gave, but was far from sure I got what these instructions meant -- I need to instruct me about TinkerPop, but as usual I am trying to follow the shortest path to get my things going ...

I tried using the open method of the Neo4jGrpah class:

gremlin> config = new BaseConfiguration()

==>org.apache.commons.configuration.BaseConfiguration@3af17be2

gremlin> config.setProperty(Neo4jGraph.CONFIG_DIRECTORY, "/Users/melancon/Documents/Recherche/Proposals/PEPS Idex COMPTRASEC/neo4j_data/neo4j_test/")

==>null

gremlin> g = Neo4jGraph.open(config)

Error starting org.neo4j.kernel.EmbeddedGraphDatabase, /Users/melancon/Documents/Recherche/Proposals/PEPS Idex COMPTRASEC/neo4j_data/neo4j_test


May I ask what the string '/tmp/neo4j' points to? Is /tmp/neo4j/ the directory where the database to be opened is stored?

I see that when the provided directory does not already contain a neo4j database, a new one is created -- in which case the open method succeeds. When the directory points to an existing neo4j database, it fails.

I guess I won't escape from digging more into the TinkerPop documentation and gain a deeper understanding of the framework -- assuming the framework can indeed do what I am aiming at :-)

Thanks again for your time and valuable input
Guy

P.S. In my post I had indicated I was running a "neo4j instance on localhost", which meant I was running the Neo4j COmmunity Edition App locally, which allows to browse and query the database from the browser at http://localhost:7474/
--

Stephen Mallette

unread,
Mar 30, 2016, 4:45:01 PM3/30/16
to Gremlin-users
This won't work:

 In my post I had indicated I was running a "neo4j instance on localhost", which meant I was running the Neo4j COmmunity Edition App locally, which allows to browse and query the database from the browser at http://localhost:7474/

Turn off Neo4j Server. Then try to connect to your existing db with the commands you've been using.  As I mentioned earlier, you would need to provide a Configuration object with HA settings, which I believe is currently possible, but we're still trying to validate/test.  

Guy Melançon

unread,
Mar 30, 2016, 4:57:22 PM3/30/16
to Gremlin-users
Neo4j Community Edition turned off. Tried the same instructions, but got the same error message (I won't include the whole stack trace unless you feel it can be useful).

I don't see what "HA settings" mean, how would you input these settings into the BaseConfiguration object (do you have a pointer to some java doc page?).

Thanks for replying so promptly,
Guy
--

Stephen Mallette

unread,
Mar 30, 2016, 5:01:28 PM3/30/16
to Gremlin-users
please provide the whole stack trace. 


Guy Melançon

unread,
Mar 30, 2016, 5:11:31 PM3/30/16
to Gremlin-users

gremlin> g = Neo4jGraph.open(config)

Error starting org.neo4j.kernel.EmbeddedGraphDatabase, /Users/melancon/Documents/Recherche/Proposals/PEPS_Idex_COMPTRASEC/neo4j_data/neo4j_test

Display stack trace? [yN] y

java.lang.RuntimeException: Error starting org.neo4j.kernel.EmbeddedGraphDatabase, /Users/melancon/Documents/Recherche/Proposals/PEPS_Idex_COMPTRASEC/neo4j_data/neo4j_test

at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:334)

at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:59)

at org.neo4j.graphdb.factory.GraphDatabaseFactory.newDatabase(GraphDatabaseFactory.java:108)

at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:95)

at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:176)

at org.neo4j.tinkerpop.api.impl.Neo4jFactoryImpl.newGraphDatabase(Neo4jFactoryImpl.java:44)

at org.neo4j.tinkerpop.api.Neo4jFactory$Builder.open(Neo4jFactory.java:32)

at org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph.<init>(Neo4jGraph.java:131)

at org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph.open(Neo4jGraph.java:145)

at org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph$open.call(Unknown Source)

at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)

at groovysh_evaluate.run(groovysh_evaluate:3)

at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:218)

at org.codehaus.groovy.tools.shell.Interpreter.evaluate(Interpreter.groovy:70)

at org.codehaus.groovy.tools.shell.Groovysh.execute(Groovysh.groovy:187)

at org.codehaus.groovy.tools.shell.Shell.leftShift(Shell.groovy:122)

at org.codehaus.groovy.tools.shell.ShellRunner.work(ShellRunner.groovy:95)

at org.codehaus.groovy.tools.shell.InteractiveShellRunner.super$2$work(InteractiveShellRunner.groovy)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)

at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)

at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1210)

at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:132)

at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:152)

at org.codehaus.groovy.tools.shell.InteractiveShellRunner.work(InteractiveShellRunner.groovy:124)

at org.codehaus.groovy.tools.shell.ShellRunner.run(ShellRunner.groovy:59)

at org.codehaus.groovy.tools.shell.InteractiveShellRunner.super$2$run(InteractiveShellRunner.groovy)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)

at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)

at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1210)

at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:132)

at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:152)

at org.codehaus.groovy.tools.shell.InteractiveShellRunner.run(InteractiveShellRunner.groovy:83)

at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:218)

at org.apache.tinkerpop.gremlin.console.Console.<init>(Console.groovy:144)

at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:218)

at org.apache.tinkerpop.gremlin.console.Console.main(Console.groovy:305)

Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.impl.transaction.state.DataSourceManager@358f38d2' was successfully initialized, but failed to start. Please see attached cause exception.

at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:513)

at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:115)

at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:330)

... 45 more

Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.NeoStoreDataSource@5073667d' was successfully initialized, but failed to start. Please see attached cause exception.

at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:513)

at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:115)

at org.neo4j.kernel.impl.transaction.state.DataSourceManager.start(DataSourceManager.java:117)

at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:507)

... 47 more

Caused by: org.neo4j.kernel.impl.storemigration.StoreUpgrader$UpgradingStoreVersionNotFoundException: 'neostore.nodestore.db' does not contain a store version, please ensure that the original database was shut down in a clean state.

at org.neo4j.kernel.impl.storemigration.UpgradableDatabase.checkUpgradeable(UpgradableDatabase.java:86)

at org.neo4j.kernel.impl.storemigration.StoreMigrator.needsMigration(StoreMigrator.java:158)

at org.neo4j.kernel.impl.storemigration.StoreUpgrader.getParticipantsEagerToMigrate(StoreUpgrader.java:259)

at org.neo4j.kernel.impl.storemigration.StoreUpgrader.migrateIfNeeded(StoreUpgrader.java:134)

at org.neo4j.kernel.NeoStoreDataSource.upgradeStore(NeoStoreDataSource.java:560)

at org.neo4j.kernel.NeoStoreDataSource.start(NeoStoreDataSource.java:461)

at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:507)

... 50 more

gremlin> 

Stephen Mallette

unread,
Mar 31, 2016, 7:34:32 AM3/31/16
to Gremlin-users
I'm not completely sure what's wrong, but note that you are using Neo4j 2.3.1 when TinkerPop 3.1.1 is bound to 2.3.0:


The root of the problem is here:

Caused by: org.neo4j.kernel.impl.storemigration.StoreUpgrader$UpgradingStoreVersionNotFoundException: 'neostore.nodestore.db' does not contain a store version, please ensure that the original database was shut down in a clean state.

which is purely a Neo4j exception. If you google around a bit you might find the solution for what's amiss here. I came across this on SO:


I wonder if you would get the same error trying to run Neo4j Server 2.3.0 against your existing 2.3.1 data which would show it was a purely a versioning issue.

Guy Melançon

unread,
Mar 31, 2016, 7:48:25 AM3/31/16
to Gremlin-users
Hmm ... might be a versioning issue indeed and yes it seems the problem is on the neo4j side.

I am able to Neo4jGraph.open a database that was previously created by opening a "brand new" database using gremlin.

I'll have a look at the pointer you gave. If I find anything useful, I'll report it here.

Thanks again for your help
Guy
--
Reply all
Reply to author
Forward
0 new messages