我正在尝试升级到Neo4j 2.0和Spring Data 3.0。在我的任何代码执行之前,我在应用程序启动时得到一个空指针。
Caused by: org.springframework.dao.InvalidDataAccessResourceUsageException: Error executing statement MATCH (ref:ReferenceNode {name:{name}}) RETURN ref; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: Error executing statement MATCH (ref:ReferenceNode {name:{name}}) RETURN ref; nested exception is java.lang.NullPointerException
at org.springframework.data.neo4j.support.query.CypherQueryEngine.query(CypherQueryEngine.java:56)
at org.springframework.data.neo4j.support.ReferenceNodes.executeQuery(ReferenceNodes.java:77)
at org.springframework.data.neo4j.support.ReferenceNodes.getReferenceNode(ReferenceNodes.java:81)
at org.springframework.data.neo4j.support.typerepresentation.SubReferenceNodeTypeRepresentationStrategy.isStrategyAlreadyInUse(SubReferenceNodeTypeRepresentationStrategy.java:95)
at org.springframework.data.neo4j.support.typerepresentation.TypeRepresentationStrategyFactory.chooseStrategy(TypeRepresentationStrategyFactory.java:56)
at org.springframework.data.neo4j.support.typerepresentation.TypeRepresentationStrategyFactory.<init>(TypeRepresentationStrategyFactory.java:39)
at org.springframework.data.neo4j.config.Neo4jConfiguration.typeRepresentationStrategyFactory(Neo4jConfiguration.java:146)
at org.springframework.data.neo4j.config.Neo4jConfiguration$$EnhancerByCGLIB$$4b018b97.CGLIB$typeRepresentationStrategyFactory$6(<generated>)
at org.springframework.data.neo4j.config.Neo4jConfiguration$$EnhancerByCGLIB$$4b018b97$$FastClassByCGLIB$$5306fd26.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:286)
at org.springframework.data.neo4j.config.Neo4jConfiguration$$EnhancerByCGLIB$$4b018b97.typeRepresentationStrategyFactory(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:160)
... 112 more
Caused by: org.springframework.dao.InvalidDataAccessResourceUsageException: Error executing statement MATCH (ref:ReferenceNode {name:{name}}) RETURN ref; nested exception is java.lang.NullPointerException
at org.springframework.data.neo4j.support.query.CypherQueryEngine.parseAndExecuteQuery(CypherQueryEngine.java:67)
at org.springframework.data.neo4j.support.query.CypherQueryEngine.query(CypherQueryEngine.java:53)
... 128 more
Caused by: java.lang.NullPointerException
at org.neo4j.cypher.ExecutionEngine.prepare(ExecutionEngine.scala:75)
at org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:60)
at org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:65)
at org.neo4j.cypher.javacompat.ExecutionEngine.execute(ExecutionEngine.java:78)
at org.springframework.data.neo4j.support.query.CypherQueryEngine.parseAndExecuteQuery(CypherQueryEngine.java:65)
... 129 more
Neo4j和Pom.xml上的spring-data依赖关系
<properties>
<spring.version>3.2.6.RELEASE</spring.version>
<springSecurity.version>3.2.0.RELEASE</springSecurity.version>
<jackson.version>1.9.13</jackson.version>
<neo4j.version>2.0.0</neo4j.version>
<springDataNeo4j.version>3.0.0.RC1</springDataNeo4j.version>
<neo4j-rest-graphdb.version>2.0.0</neo4j-rest-graphdb.version>
</properties>
<!--Neo4j-->
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>${neo4j.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>${springDataNeo4j.version}</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-rest-graphdb</artifactId>
<version>${neo4j-rest-graphdb.version}</version>
</dependency>
上下文文件
<neo4j:config graphDatabaseService="graphDatabaseService" />
<bean id="graphDatabaseService" class="org.neo4j.rest.graphdb.RestGraphDatabase">
<constructor-arg value="http://localhost:7474/db/data"/>
</bean>
<context:annotation-config />
Neo4j启动并运行。
通过http://localhost:7474/browser/
连接时,一切正常,包括违规查询MATCH(ref:ReferenceNode {name:{name}})RETURN ref;
答案 0 :(得分:1)
我相信您不需要任何org.neo4j.*
依赖项。也许只适用于<artifactId>spring-data-neo4j</artifactId>
和<artifactId>spring-data-neo4j-rest</artifactId>
。这是您应该尝试的配置:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>3.0.0.RC1</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j-rest</artifactId>
<version>3.0.0.RC1</version>
</dependency>
<强>更新强>
可疑的是,org.springframework.data.neo4j.support.ReferenceNodes
getReferenceNode
(http://bit.ly/1eDYlYS)中getReferenceNode
生成了错误消息。
org.springframework.data.neo4j.support.typerepresentation.SubReferenceNodeTypeRepresentationStrategy
方法仅在SDN的某个地方调用:ReferenceNode
(http://bit.ly/LW5gly)。
此调用正在寻找标签为name
且属性root
等于CREATE (n:ReferenceNode {name:"root"}) RETURN n;
的节点。
所以我建议尝试使用Cypher创建这样一个节点:
{{1}}
并查看错误是否仍然存在。