这是我用Spring Data Neo4j骨架应用程序构建的PlayFramework:
https://github.com/tomasmuller/playframework-neo4j-template
在第一个play run
期间,一切正常。通过Netty的PlayFramework以开发模式启动。所以我们可以继续编程并点击刷新来查看结果。
但可能有一些与Neo4j事务管理器相关的缺失配置。或者甚至这可能与PlayFramework的开发模式有关。
例如,尝试更改index.scala.html
的第13行以获取不同的标题,并重新加载索引页而不重新启动服务器。
事实证明以下例外:
play.api.PlayException: Cannot init the Global object[null] ... Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphDatabaseService': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.neo4j.kernel.EmbeddedGraphDatabase]: Constructor threw exception; nested exception is java.lang.RuntimeException: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.StoreLockerLifecycleAdapter@20346642' was successfully initialized, but failed to start. Please see attached cause exception. ... Caused by: org.neo4j.kernel.StoreLockException: Unable to obtain lock on store lock file: target/neo4j-db/store_lock at org.neo4j.kernel.StoreLocker.checkLock(StoreLocker.java:90) ~[neo4j-kernel-1.9.RC1.jar:1.9.RC1] ...
我尝试了一些配置(没有成功)并记录在repository issue n.1。
发生了什么事?这是一个配置问题还是与Spring Data Neo4j和PlayFramework的组合有关?
答案 0 :(得分:1)
“无法获取锁定”听起来像文件系统问题(检查目标/ neo4j-db / dir是否有权限?),可能有两个已创建?
答案 1 :(得分:0)
通过getGraphDatabaseService.shutdown()
app/Global.scala
方法从Neo4jTemplate调用onStop
解决了这个问题。
/**
* Sync the context lifecycle with Play's.
* @param app
*/
override def onStop(app: Application) {
val neo4jTemplate:Neo4jTemplate = ctx.getBean(classOf[Neo4jTemplate]);
neo4jTemplate.getGraphDatabaseService.shutdown();
ctx.stop()
}
提取请求here。