0

this is my configuration:

@Bean
public org.neo4j.ogm.config.Configuration getConfiguration() {
    org.neo4j.ogm.config.Configuration config = new org.neo4j.ogm.config.Configuration();
    config.driverConfiguration().setDriverClassName("org.neo4j.ogm.drivers.http.driver.HttpDriver")
                                .setCredentials("neo4j", "neo4j")
                                .setURI("http://localhost:7474");
    return config;
}

@Override
public SessionFactory getSessionFactory() {
    return new SessionFactory(getConfiguration(), "movies.spring.data.neo4j.domain");
}

@Bean
@Override
// @Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public Session getSession() throws Exception {
    return getSessionFactory().openSession();
}

everytime i want to get the result from neo4j and it hits me a nullPointerError as shown:

Exception in thread "main" java.lang.NullPointerException
    at org.neo4j.ogm.context.RestModelMapper.mapEntity(RestModelMapper.java:153)
    at org.neo4j.ogm.context.RestModelMapper.map(RestModelMapper.java:76)
    at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.query(ExecuteQueriesDelegate.java:94)
    at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.query(ExecuteQueriesDelegate.java:73)
    at org.neo4j.ogm.session.Neo4jSession.query(Neo4jSession.java:313)
    at movies.spring.data.neo4j.controllers.BenchmarkDeleteController.run(BenchmarkDeleteController.java:57)

where the specified line 57 is:

Result results = neoSession.query("MATCH (n:USER) WHERE n.isBanned={param} RETURN n as user",
        Collections.<String, Object>singletonMap("param", 1));

I wonder what could be the problem? I made sure that the session isnt null.

Luanne
  • 19,145
  • 1
  • 39
  • 51
kenlz
  • 461
  • 7
  • 22
  • Which version of spring data neo4j? And does this query return null? – Luanne Jun 08 '16 at 07:28
  • @Luanne the query returns 17 nodes when I ran it with the browser and I am currently using the SDN 4.1.1.RELEASE – kenlz Jun 08 '16 at 08:34
  • Hmm, would you be able to supply a small dataset + test code? Unable to tell what's wrong. If so, please send to luanne at graphaware dot com or open an issue at https://github.com/neo4j/neo4j-ogm/issues – Luanne Jun 08 '16 at 09:06
  • Sure I'll shoot you an email shortly.. thanks @Luanne – kenlz Jun 08 '16 at 12:09

1 Answers1

1

If you do not have a node entity that the results can be mapped to, the RestModelMapper throws a NullPointerException in Neo4j-OGM 2.0.1 (which SDN 4.1.1 depends on). This was fixed in Neo4j OGM 2.0.2- https://github.com/neo4j/neo4j-ogm/issues/150

Please check that the nodes returned can be mapped to node entities (their labels should match) and then override the neo4j-ogm-code and driver dependencies to use 2.0.2.

Luanne
  • 19,145
  • 1
  • 39
  • 51