Spring Data Neo4j RestGraphDatabase抛出NullPointerException

时间:2014-11-11 19:15:31

标签: neo4j spring-data-neo4j

尝试使用远程REST图形数据库配置设置Neo4J。我有一个本地的嵌入式设置工作正常。唯一的变化是如何配置GraphDatabaseService。

我使用的是Spring Data Neo4J 3.2.1和Neo4J 2.1.4。

想法?

配置:

package com.toyfiles.configuration;

import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.rest.graphdb.RestGraphDatabase;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.data.neo4j.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.config.Neo4jConfiguration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Configuration
@Profile("RestDBServer")
@EnableTransactionManagement
@EnableNeo4jRepositories(basePackages = "com.toyfiles.dataservices")
public class RestDBConfig extends Neo4jConfiguration {

    public RestDBConfig() {
        setBasePackage("com.toyfiles");
    }

    @Bean
    public GraphDatabaseService graphDatabaseService() {
        return new RestGraphDatabase("http://localhost:7474/db/data");
    }
}

这是例外

 Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.data.neo4j.core.GraphDatabase org.springframework.data.neo4j.config.Neo4jConfiguration.graphDatabase()] threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:188)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:586)
... 136 more
Caused by: java.lang.NullPointerException
at org.neo4j.cypher.ExecutionEngine.createCompiler(ExecutionEngine.scala:149)
at org.neo4j.cypher.ExecutionEngine.<init>(ExecutionEngine.scala:48)
at org.neo4j.cypher.javacompat.ExecutionEngine.createInnerEngine(ExecutionEngine.java:59)
at org.neo4j.cypher.javacompat.ExecutionEngine.<init>(ExecutionEngine.java:43)
at org.springframework.data.neo4j.support.query.CypherQueryEngineImpl.<init>(CypherQueryEngineImpl.java:41)
at org.springframework.data.neo4j.support.DelegatingGraphDatabase.createCypherQueryEngine(DelegatingGraphDatabase.java:219)
at org.springframework.data.neo4j.support.DelegatingGraphDatabase.queryEngine(DelegatingGraphDatabase.java:208)
at org.springframework.data.neo4j.support.DelegatingGraphDatabase.queryEngine(DelegatingGraphDatabase.java:215)
at org.springframework.data.neo4j.support.DelegatingGraphDatabase.queryEngine(DelegatingGraphDatabase.java:201)
at org.springframework.data.neo4j.support.schema.SchemaIndexProvider.<init>(SchemaIndexProvider.java:36)
at org.springframework.data.neo4j.support.DelegatingGraphDatabase.<init>(DelegatingGraphDatabase.java:72)
at org.springframework.data.neo4j.support.DelegatingGraphDatabase.<init>(DelegatingGraphDatabase.java:67)
at org.springframework.data.neo4j.config.Neo4jConfiguration.graphDatabase(Neo4jConfiguration.java:259)
at com.toyfiles.configuration.RestDBConfig$$EnhancerBySpringCGLIB$$1110ba63.CGLIB$graphDatabase$27(<generated>)
at com.toyfiles.configuration.RestDBConfig$$EnhancerBySpringCGLIB$$1110ba63$$FastClassBySpringCGLIB$$679e9620.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:312)
at com.toyfiles.configuration.RestDBConfig$$EnhancerBySpringCGLIB$$1110ba63.graphDatabase(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:166)
... 137 more

1 个答案:

答案 0 :(得分:2)

有时发帖会引发一个想法。

我需要使用SpringRestGraphDatabase,而不仅仅是RestGraphDatabase。