spring-projects / spring-data-neo4j

Provide support to increase developer productivity in Java when using Neo4j. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
http://spring.io/projects/spring-data-neo4j
Apache License 2.0
832 stars 618 forks source link

NPE in Neo4jTemplate.getDefaultConverter [DATAGRAPH-471] #1035

Closed spring-projects-issues closed 7 years ago

spring-projects-issues commented 10 years ago

Lee Standen opened DATAGRAPH-471 and commented

Tested in BUILD-SNAPSHOT 3.0 and 3.1 series. Perhaps this isn't an intended use case, or I'm misreading examples...

Basic Spring Boot App

@EnableAutoConfiguration
@EnableNeo4jRepositories
@ComponentScan
public class Starter extends Neo4jConfiguration {

  public static void main(String[] args) throws Exception {
    SpringApplication.run(Starter.class, args);
  }

  @Bean
  public GraphDatabaseService graphDatabaseService() {
    return new GraphDatabaseFactory().newEmbeddedDatabase("target/graph.db");
  }

}

Two annotated classes:

@Data
@NodeEntity
public class Device {
  @GraphId
  Long id;
  @Indexed
  private String name;
  @Indexed
  private String uuid;
  @RelatedTo(type = "HAS_INTERFACE")
  private Set<Interface> interfaces;
}
@NodeEntity
@Data
public class Interface {
  @GraphId
  private Long id;
  @Indexed
  private String uuid;
  private String name;
  @RelatedTo
  private Device device;
}

And Spring Data Neo4j Repository:

public interface DeviceRepository extends GraphRepository<Device> {

}

Results in the following stacktrace:

Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.data.neo4j.support.Neo4jTemplate org.springframework.data.neo4j.config.Neo4jConfiguration.neo4jTemplate() throws java.lang.Exception] 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)
    ... 17 more
Caused by: java.lang.NullPointerException
    at org.springframework.data.neo4j.support.Neo4jTemplate.getDefaultConverter(Neo4jTemplate.java:558)
    at org.springframework.data.neo4j.support.Neo4jTemplate.updateDependencies(Neo4jTemplate.java:126)
    at org.springframework.data.neo4j.support.Neo4jTemplate.<init>(Neo4jTemplate.java:122)
    at org.springframework.data.neo4j.config.Neo4jConfiguration.neo4jTemplate(Neo4jConfiguration.java:134)
    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:166)
    ... 18 more

Affects: 3.1 M1 (Dijkstra)

1 votes, 3 watchers

spring-projects-issues commented 10 years ago

Lee Standen commented

I've also noticed that running a maven clean, followed by trying to launch the application from my IDE again results in a different exception ... after launching a half dozen times or so, it launches and then hits the above issue:

Caused by: java.lang.IllegalArgumentException: requirement failed: Can't work with a null graph database
    at scala.Predef$.require(Predef.scala:233)
    at org.neo4j.cypher.ExecutionEngine.<init>(ExecutionEngine.scala:35)
    at org.neo4j.cypher.javacompat.ExecutionEngine.<init>(ExecutionEngine.java:53)
    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:32)
    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:257)
    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.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:589)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
    ... 21 more
spring-projects-issues commented 7 years ago

Nicolas Mervaillie commented

In order to give users a better vision of what’s happening on SDN, we are bulk closing several issues because they are no more relevant, or related to old and un-maintained SDN versions. We tried to keep the issues that are still relevant, like feature requests that are still absent from SDN. However, some may have been closed by error. If so, please feel free to reopen.