What is the proper configuration for Spring Data Neo4j and PlayFramework 2.1.1?
Here is a PlayFramework with Spring Data Neo4j skeleton app that I've built:
https://github.com/tomasmuller/playframework-neo4j-template
During the first play run
everything works fine. PlayFramework via Netty starts in dev mode. So we can continue programming and hit refresh to see the result.
But probably there's some missing configuration related to Neo4j transaction manager. Or even this can be related to dev mode of PlayFramework.
As an example, try changing the line 13 of index.scala.html
for a different title, and reload the index page without restart the server.
It turns out the following exception:
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] ...
I tried some configurations (without success) and documented at the repository issue n.1.
What is going on? It is a configuration issue or is related to the combination of Spring Data Neo4j and PlayFramework?
“无法获得锁定”听起来像文件系统问题(检查目标/ neo4j-db / dir的权限等),也许有两个创建?
Calling getGraphDatabaseService.shutdown()
from Neo4jTemplate in the app/Global.scala
onStop
method solved this problem.
/**
* 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()
}
Pull request here.
链接地址: http://www.djcxy.com/p/68766.html