K.E. K.E. - 1 year ago 108
Java Question

Spring Data Neo4j NullPointerException when deploying multiple versions on tomcat

I am working on a Java Rest Service with Spring MVC (4.2.0.RELEASE) including a Neo4j database. Therefore Spring Data Neo4j (4.1.1.RELEASE) is used.

The SDN configuration looks like this:

@ComponentScan(basePackages = { "com.xxx.yyy" })
@EnableNeo4jRepositories(basePackages = "com.xxx.yyy.dao.repo")
public class Neo4jConfig extends Neo4jConfiguration {

private ApplicationProperties properties;

public SessionFactory getSessionFactory() {
return new SessionFactory(getConfiguration(), "com.xxx.yyy.dao.beans");

public Neo4jOperations neo4jTemplate() throws Exception {
return new Neo4jTemplate(getSession());

public org.neo4j.ogm.config.Configuration getConfiguration() {
org.neo4j.ogm.config.Configuration config = new org.neo4j.ogm.config.Configuration();

.setCredentials(this.properties.getNeo4jUser(), this.properties.getNeo4jPassword());

return config;

@Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)
public Session getSession() throws Exception {
return super.getSession();


The application is deployed on a Tomcat7 in production environment. Everything works like a charm if there is only one version of the application deployed and the version flag is not filled in.

For a zero downtime deployment I want to use the version flag on the tomcat to deploy multiple versions. If I do so the application is not working anymore because of a
in the


at org.neo4j.ogm.context.RestModelMapper.mapEntity(RestModelMapper.java:153) ~[neo4j-ogm-core-2.0.1.jar:?]
at org.neo4j.ogm.context.RestModelMapper.map(RestModelMapper.java:76) ~[neo4j-ogm-core-2.0.1.jar:?]
at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.query(ExecuteQueriesDelegate.java:94) ~[neo4j-ogm-core-2.0.1.jar:?]
at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.query(ExecuteQueriesDelegate.java:73) ~[neo4j-ogm-core-2.0.1.jar:?]
at org.neo4j.ogm.session.Neo4jSession.query(Neo4jSession.java:313) ~[neo4j-ogm-core-2.0.1.jar:?]

This problem occurs only if I use the version flag on tomcat. Does anyboby know what is the problem here?

Answer Source

I finally solved this issue by changing the version of the OGM HTTP Driver and the Spring Data Neo4j dependency.



With this settings the deployment with the Tomcat version flag https://tomcat.apache.org/tomcat-7.0-doc/config/context.html is now working.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download