创建要在neo4j服务器上运行的maven项目时出错



如何解决此异常:

线程"main"中出现异常org.neo4j.kernel.lifecycle.lifecycle异常:无法转换组成部分'org.neo4j.kernel.impl.pagecache.PageCacheLifecycle@4b845428'来自停止以关闭。请参阅附件中的原因异常org.neo4j.kernel.hifecycle.LifeSupport$LifecycleInstance.shutdown(LifeSupport.java:559)在org.neo4j.kernel.hifecycle.LifeSupport.shutdown(LifeSupport.java:200)在org.neo4j.kernel.InternalAbstractGraphDatabase.shutdown(InternalAbstractGraphicDatabase.java:685)在org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphicDatabase.java:340)在org.neo4j.kernel.EmbeddedGraphDatabase.(EmbeddedGraphDatabase.java:59)在org.neo4j.graphdb.factory.GraphDatabaseFactory.newDatabase(GraphDatabaseFactory.java:108)在org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:95)在org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:176)在org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:67)在neo4jExamples.secondExample.main(secondExample.java:18)由以下原因引起:java.lang.IollegalStateException:在文件仍然映射:neostore.relationshiptypestore.db.names(1映射)org.neo4j.io.pagecache.impl.muninn.MuninnPageCache.colose(MuninnPageCache.java:473)在org.neo4j.kernel.impl.pagecache.PageCacheLifecycle。shutdown(PageCacheLifecycle。java:42)在org.neo4j.kernel.hifecycle.LifeSupport$LifecycleInstance.shutdown(LifeSupport.java:555)…还有9个

我的代码是:

package neo4jExamples;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
public class secondExample {
public static void main(String[] args) {
GraphDatabaseService graphDb;
Node firstNode;
Node secondNode;
Relationship relationship;
graphDb = new GraphDatabaseFactory().newEmbeddedDatabase("/var/lib/neo4j/data/graph.db");
registerShutdownHook( graphDb );
try (Transaction tx = graphDb.beginTx()) {
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 " );
System.out.print( firstNode.getProperty( "message" ) );
System.out.print( relationship.getProperty( "message" ) );
System.out.print( secondNode.getProperty( "message" ) );

tx.success();
}
}
private static void registerShutdownHook(final GraphDatabaseService graphDb) {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
graphDb.shutdown();
}
});
}
}

我可以在这里想到两个原因:

  1. 另一个java进程正在访问某些文件,除非其他有助于考虑kill -9 <pid>
  2. 仔细检查graph.db文件夹中的文件权限

相关内容

  • 没有找到相关文章

最新更新