使用Spring创建存储库bean时出错

时间:2013-01-28 18:32:57

标签: scala neo4j spring-data-neo4j

我设置了Neo4j-Kernel 1.9M04和Spring-Data-Neo4j 2.1.0 RELEASE。

更确切地说,这是我的依赖项(来自我的SBT文件):

    "org.springframework" % "spring-aop" % "3.2.0.RELEASE",
    "org.springframework" % "spring-aspects" % "3.2.0.RELEASE",
    "org.springframework" % "spring-beans" % "3.2.0.RELEASE",
    "org.springframework.data" % "spring-data-commons-core" % "1.4.0.RELEASE",
    "org.springframework" % "spring-expression" % "3.2.0.RELEASE",
    "org.springframework" % "spring-jdbc" % "3.2.0.RELEASE",
    "org.springframework" % "spring-orm" % "3.2.0.RELEASE",
    "org.springframework" % "spring-test" % "3.2.0.RELEASE",
    "org.springframework" % "spring-tx" % "3.2.0.RELEASE",
    "org.springframework.data" % "spring-data-neo4j" % "2.1.0.RELEASE" excludeAll(
      ExclusionRule(organization = "com.sun.jdmk"),
      ExclusionRule(organization = "com.sun.jmx"),
      ExclusionRule(organization = "javax.jms")
      ),
    "org.neo4j" % "neo4j" % "1.9.M04",
    "org.neo4j" % "neo4j-kernel" % "1.9.M04" % "test" classifier "tests" classifier "",
    "asm" % "asm-all" % "3.1",
    "org.specs2" %% "specs2" % "1.13" % "test" withSources(),
    "org.springframework.data" % "spring-data-neo4j-rest" % "2.1.0.RELEASE"

在运行时,尝试自动装配neo4j存储库,我有这个堆栈:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.data.neo4j.config.Neo4jConfiguration#0': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/neo4j/kernel/impl/core/LockReleaser
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:532) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
Caused by: java.lang.NoClassDefFoundError: org/neo4j/kernel/impl/core/LockReleaser
    at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.7.0_07]
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2442) ~[na:1.7.0_07]
    at java.lang.Class.getDeclaredMethods(Class.java:1808) ~[na:1.7.0_07]
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:384) ~[spring-orm-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:322) ~[spring-orm-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:844) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
Caused by: java.lang.ClassNotFoundException: org.neo4j.kernel.impl.core.LockReleaser
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366) ~[na:1.7.0_07]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355) ~[na:1.7.0_07]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.7.0_07]
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354) ~[na:1.7.0_07]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423) ~[na:1.7.0_07]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356) ~[na:1.7.0_07]

我注意到班级org/neo4j/kernel/impl/core/LockReleaser已从Neo4J 1.9M0X中消失。

错误似乎来自"org.springframework.data" % "spring-data-neo4j-rest" % "2.1.0.RELEASE"

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

看起来spring-orm是针对不同版本的neo4j构建的,而不是你在运行时尝试使用它们(它们是不兼容的)。

可能的解决方案:

  • 使用旧版本的neo4j。
  • 针对当前版本的neo4j自行构建弹簧。可能你必须自己移动spring-orm。