2013-09-27 76 views
2

無法連接到neo4j數據庫通過應用程序獲取下面的錯誤。如何解決org.neo4j.kernel.StoreLockException:無法創建鎖定文件異常?

Exception in thread "main" java.lang.RuntimeException: org.neo4j.kernel.lifecycle.LifecycleException: Component '[email protected]' 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 '[email protected]' 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) 

請建議我解決此問題..

回答

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

+0

感謝您的答覆TASM這個過程中,我殺了其他進程並重新啓動應用程序,但現在面臨上述問題.. – Sujana

+1

您正在使用兩個不同版本的庫。可能一個是1.7.X,另一個是1.9.2。嘗試驗證所有的libs版本的neo4j – Tasm

相關問題