当前位置: 首页 > 知识库问答 >
问题:

Spring数据Neo4j RestGraphDatabase抛出NullPointerException

柳昊焱
2023-03-14

正在尝试使用远程REST图形数据库配置设置Neo4J。我已经得到了一个本地的嵌入式设置,可以正常工作。唯一的变化是GraphDatabaseService的配置方式。

我使用的是Spring数据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个答案

闻人博
2023-03-14

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

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

 类似资料: