我的neo4j服务器运行良好,但我的服务器重启并且neo4j没有启动
服务器:Ubuntu 13.10
jdk:oracle jdk
这是错误:
SEVERE:
org.neo4j.server.ServerStartupException: Starting Neo4j Server failed: Error starting org.neo4j.kernel.EmbeddedGraphDatabase, /var/lib/neo4j/data/graph.db
at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:209)
at org.neo4j.server.Bootstrapper.start(Bootstrapper.java:87)
at org.neo4j.server.Bootstrapper.main(Bootstrapper.java:50)
Caused by: java.lang.RuntimeException: Error starting org.neo4j.kernel.EmbeddedGraphDatabase, /var/lib/neo4j/data/graph.db
at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:333)
at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:63)
at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:92)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:198)
at org.neo4j.kernel.impl.recovery.StoreRecoverer.recover(StoreRecoverer.java:115)
at org.neo4j.server.preflight.PerformRecoveryIfNecessary.run(PerformRecoveryIfNecessary.java:59)
at org.neo4j.server.preflight.PreFlightTasks.run(PreFlightTasks.java:70)
at org.neo4j.server.AbstractNeoServer.runPreflightTasks(AbstractNeoServer.java:319)
at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:144)
... 2 more
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.extension.KernelExtensions@4b9de054' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:504)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:115)
at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:310)
... 10 more
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.index.lucene.LuceneKernelExtension@5df0330b' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:504)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:115)
at org.neo4j.kernel.extension.KernelExtensions.start(KernelExtensions.java:118)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:498)
... 12 more
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.index.impl.lucene.LuceneDataSource@3fc9dd8c' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:504)
at org.neo4j.kernel.lifecycle.LifeSupport.bringToState(LifeSupport.java:411)
at org.neo4j.kernel.lifecycle.LifeSupport.add(LifeSupport.java:324)
at org.neo4j.kernel.impl.transaction.XaDataSourceManager.registerDataSource(XaDataSourceManager.java:236)
at org.neo4j.index.lucene.LuceneKernelExtension.start(LuceneKernelExtension.java:79)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:498)
... 15 more
Caused by: java.lang.NullPointerException
at org.neo4j.kernel.impl.index.IndexProviderStore.<init>(IndexProviderStore.java:66)
at org.neo4j.index.impl.lucene.LuceneDataSource.newIndexStore(LuceneDataSource.java:301)
at org.neo4j.index.impl.lucene.LuceneDataSource.start(LuceneDataSource.java:224)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:498)
... 20 more
Jan 20, 2014 1:02:28 PM org.neo4j.server.logging.Logger log
SEVERE: Failed to start Neo Server on port [7474]
答案 0 :(得分:0)
我以前遇到过这个问题。后来我想出了一些你需要确保妥善处理的要点。
现在前3个不太可能导致你的问题,所以我做的是我抓住了抛出的异常然后删除了tm_tx_log.1文件然后初始化了服务。不是万无一失,而是一种解决方法。
public class GraphDB {
private static GraphDB graph = null;
private static final String DB_PATH = "target/neo4j-db";
private static GraphDatabaseService graphService = null;
protected GraphDB() {
try{
graphService = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH);
registerShutdownHook(graphService);
}catch(Exception e){
File file = new File(DB_PATH+"/tm_tx_log.1");
file.delete();
}
}
public static GraphDB getInstance() {
if (graph == null) {
graph = new GraphDB();
}
return graph;
}
public GraphDatabaseService getGraphDbService() {
return graphService;
}
public void clearDb() {
try {
// FileUtils.deleteRecursively();
File files = new File(DB_PATH);
for(File file : files.listFiles()){
FileDeleteStrategy.FORCE.delete(file);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public void shutDown() {
System.out.println();
System.out.println("Shutting down database ...");
graphService.shutdown();
}
private static void registerShutdownHook(final GraphDatabaseService graphDb) {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
graphDb.shutdown();
}
});
}
}
在你的主要部分中,当graphService为null时,调用处理的情况。
public static void main(String[] args) {
GraphDB graphDb = GraphDB.getInstance();
if(graphDb == null){
graphDb = GraphDB.getInstance();
}
}