2

由于出现以下错误,无法通过应用连接到 neo4j DB。

Exception in thread "main" java.lang.RuntimeException: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.StoreLockerLifecycleAdapter@1b09468' 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 org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:69)
    at com.Neo4J.src.EmbeddedNeo4j.createDb(EmbeddedNeo4j.java:52)
    at com.Neo4J.src.EmbeddedNeo4j.main(EmbeddedNeo4j.java:42)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.StoreLockerLifecycleAdapter@1b09468' 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)
    ... 6 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)
    ... 8 more

我的程序代码是,

new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH).shutdown();
        createLock();
        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();
        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();

这里的 creatLock() 方法代码是,

StoreLocker lock = new StoreLocker(new DefaultFileSystemAbstraction());
            lock.checkLock(new File(DB_PATH));
            lock.release();
            new File(DB_PATH, "store_lock").createNewFile();

请帮我解决这个问题............

现在新的例外是,

Sep 27, 2013 2:20:39 PM org.neo4j.server.logging.Logger log
INFO: Starting Neo Server on port [7474] with [40] threads available
2013-09-27 14:20:39.533:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
Sep 27, 2013 2:20:39 PM 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:42)

请建议我解决这个问题..

4

1 回答 1

1

此问题的典型原因是拥有该锁的另一个进程。尝试使用

ps aux | grep java

或类似的东西

这无助于尝试查看来源

http://grepcode.com/file/repo1.maven.org/maven2/org.neo4j/neo4j-kernel/1.9.2/org/neo4j/kernel/StoreLocker.java

于 2013-09-27T08:21:14.970 回答