0

my local neo4j db path is C:\neo4j-community-1.9.3_bup

I have created a simple java program to connect to neo4j DB and insert some nodes.

But after insertion when i am trying to retrive these nodes through Neo4jDataBrower these are not listing.

The code i have used is taken from neo4j portal itself,

    String DB_PATH = "C\\neo4j-community-1.9.3_bup";
    Map<String, String> config = new HashMap<String, String>();
    config.put( "neostore.nodestore.db.mapped_memory", "10M" );
    config.put( "string_block_size", "60" );
    config.put( "array_block_size", "300" );
    graphDb = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(DB_PATH).setConfig(config).newGraphDatabase();
    registerShutdownHook( graphDb );
    Transaction tx = graphDb.beginTx();
    try
    {
        firstNode = graphDb.createNode();
        firstNode.setProperty( "message", "Hello, " );
        secondNode = graphDb.createNode();
        secondNode.setProperty( "message", "World!" );
        relationship = firstNode.createRelationshipTo( secondNode, RelTypes.KNOWS );
        relationship.setProperty( "message", "brave Neo4j " );
        tx.success();
    }
    finally
    {
        tx.finish();
    }

Why its not working?

please suggest me..is there some problem vth path i have given or problem vth code?

Hi Werner,

The runtime exception is

Exception in thread "main" java.lang.RuntimeException:
 org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.StoreLockerLifecycleAdapter@406199' was successfully initialized, but failed to start. Please see attached cause exception.
    at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:280)
    at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:106)
    at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:88)
    at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:207)
    at com.Neo4J.src.EmbeddedNeo4j.createDb(EmbeddedNeo4j.java:54)
    at com.Neo4J.src.EmbeddedNeo4j.main(EmbeddedNeo4j.java:38)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.StoreLockerLifecycleAdapter@406199' was successfully initialized, but failed to start. Please see attached cause exception.
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:497)
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:104)
    at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:258)
    ... 5 more
Caused by: org.neo4j.kernel.StoreLockException: Could not create lock file
    at org.neo4j.kernel.StoreLocker.checkLock(StoreLocker.java:74)
    at org.neo4j.kernel.StoreLockerLifecycleAdapter.start(StoreLockerLifecycleAdapter.java:40)
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:491)
    ... 7 more

New Log,

Exception in thread "main" java.lang.RuntimeException: 

org.neo4j.kernel.lifecycle.LifecycleException: 

Component 'org.neo4j.kernel.impl.transaction.TxManager@1827284' was successfully initialized, but failed to start. Please see attached cause exception.
    at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:280)
    at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:106)
    at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:88)
    at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:207)
    at com.Neo4J.src.EmbeddedNeo4j.createDb(EmbeddedNeo4j.java:57)
    at com.Neo4J.src.EmbeddedNeo4j.main(EmbeddedNeo4j.java:41)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component
 'org.neo4j.kernel.impl.transaction.TxManager@1827284' was successfully initialized, but failed to start. Please see attached cause exception.
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:497)
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:104)
    at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:258)
    ... 5 more
Caused by: org.neo4j.graphdb.TransactionFailureException:
 Unable to start TM, no active tx log file found but found either tm_tx_log.1 or tm_tx_log.2 file, please set one of them as active or remove them.
    at org.neo4j.kernel.impl.transaction.TxManager.openLog(TxManager.java:750)
    at org.neo4j.kernel.impl.transaction.TxManager.start(TxManager.java:138)
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:491)
    ... 7 more

New exception,

Sep 27, 2013 11:09:27 AM org.neo4j.server.logging.Logger log
INFO: Starting Neo Server on port [7474] with [40] threads available
2013-09-27 11:09:27.665:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
Sep 27, 2013 11:09:27 AM org.neo4j.server.logging.Logger log
INFO: Using database at C:\neo4j-community-1.9.3_bup\data\graph.db
Exception in thread "main" java.lang.NoSuchFieldError: remote_shell_enabled
    at org.neo4j.server.database.Database.createDatabase(Database.java:77)
    at org.neo4j.server.database.Database.<init>(Database.java:55)
    at org.neo4j.server.NeoServerWithEmbeddedWebServer.startDatabase(NeoServerWithEmbeddedWebServer.java:179)
    at org.neo4j.server.NeoServerWithEmbeddedWebServer.start(NeoServerWithEmbeddedWebServer.java:93)
    at org.neo4j.server.Bootstrapper.start(Bootstrapper.java:87)
    at org.neo4j.server.Bootstrapper.start(Bootstrapper.java:76)
    at com.Neo4J.src.EmbeddedNeo4j.createDb(EmbeddedNeo4j.java:69)
    at com.Neo4J.src.EmbeddedNeo4j.main(EmbeddedNeo4j.java:41)
Mohamed Amine
  • 2,264
  • 1
  • 23
  • 36
Sujana
  • 331
  • 1
  • 3
  • 12

1 Answers1

0

C\\neo4j-community-1.9.3_bup is not a valid path. It should be C:\\neo4j-community-1.9.3_bup.

But still, it may not be valid, if you are pointing to your Neo4J installation directory, and not the database directory itself. If that is the case, the path should be C:\\neo4j-community-1.9.3_bup\data\graph.db

Edited:

To prevent the locking situation, stop your running Neo4J instance, and start your own database with its own web console, by inserting these lines after the line where you initialize your embedded database:

Configurator configurator = new ServerConfigurator((GraphDatabaseAPI)graphDb);
configurator.configuration().setProperty(Configurator.WEBSERVER_ADDRESS_PROPERTY_KEY, "127.0.0.1");
configurator.configuration().setProperty(Configurator.WEBSERVER_PORT_PROPERTY_KEY, 7474);

WrappingNeoServerBootstrapper bootstrapper = new WrappingNeoServerBootstrapper((GraphDatabaseAPI)graphDb, configurator);
bootstrapper.start();
Werner Kvalem Vesterås
  • 10,226
  • 5
  • 43
  • 50
  • Hi Werner,Thanks for ur reply,Now i have replaced the path with C:\\neo4j-community-1.9.3_bup\data\graph.db. but getting runtime exception, i have added the same above.. – Sujana Sep 26 '13 at 10:37
  • Hi, But in the programme graphDb is of type GraphDatabaseService,but here the constructer is expecting GraphDatabaseAPI. – Sujana Sep 26 '13 at 12:13
  • See my updated answer, where I cast `graphDb` to `GraphDatabaseAPI` – Werner Kvalem Vesterås Sep 26 '13 at 12:32
  • Hi Werner, yes i have tried that, but even though the same runtime exception is coming.i have stopped the neo4j instance and executed this, though the same exception... – Sujana Sep 26 '13 at 13:03
  • I have successfully started your example code on my own computer with no problems. – Werner Kvalem Vesterås Sep 26 '13 at 13:31
  • There i have missed out some jars werner.But later i got a new exception like above, can u please help me to sort it out.. – Sujana Sep 27 '13 at 05:45
  • I even included this bit to config properties map. config.put( "remote_shell_enabled", "true" );.but the ame exception is coming. – Sujana Sep 27 '13 at 05:48
  • Sorry, I have no idea what this exception means. I have never experienced it myself. – Werner Kvalem Vesterås Sep 27 '13 at 06:14
  • Hi werner, can you please give me the jar info which you have used for running this programme successfully.. – Sujana Oct 01 '13 at 05:13
  • I've created a Gist with a Maven project file with the dependencies, and a Java class here: https://gist.github.com/vesteraas/6774465 – Werner Kvalem Vesterås Oct 01 '13 at 06:11
  • Here i have not created any spring project,i have just written this simple java programme in eclipse and trying to run it as a plain java app. – Sujana Oct 01 '13 at 06:22
  • is there any issue vth that? – Sujana Oct 01 '13 at 06:23
  • It is not spring, it is Maven. It manages your build dependencies, among other things. You need more than one jar to get your program up and running. I've updated the Gist with a list of the jar files that Maven collects when building. – Werner Kvalem Vesterås Oct 01 '13 at 06:34