Null pointer Exception in Neo4J OGM

I am intermittently getting an NPE when I execute a query under mild load.

java.lang.NullPointerException: null
 at org.neo4j.ogm.metadata.MetaData.classInfo(MetaData.java:123)
 at org.neo4j.ogm.context.GraphEntityMapper.executePostLoad(GraphEntityMapper.java:193)
 at org.neo4j.ogm.context.GraphEntityMapper.executePostLoad(GraphEntityMapper.java:180)
 at org.neo4j.ogm.context.GraphEntityMapper.map(GraphEntityMapper.java:120)
 at org.neo4j.ogm.context.GraphEntityMapper.map(GraphEntityMapper.java:83)
 at org.neo4j.ogm.context.RestModelMapper.map(RestModelMapper.java:84)
 at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.lambda$query$0(ExecuteQueriesDelegate.java:137)
 at org.neo4j.ogm.session.Neo4jSession.doInTransaction(Neo4jSession.java:590)
 at org.neo4j.ogm.session.Neo4jSession.doInTransaction(Neo4jSession.java:564)
 at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.query(ExecuteQueriesDelegate.java:134)
 at org.neo4j.ogm.session.Neo4jSession.query(Neo4jSession.java:435)

I have a Micronaut (Java) application that uses Neo4J-OGM, executes the query using Session on a database in Aura (cloud service).

Any idea why this call fail sometimes and work other times? Especially if there are no simultaneous calls.

Could. you provide us more insights on your problem?
How does the domain object looks like, you are trying to get out of the call?
What query do you issue?

The message only tells me that Neo4j-OGM tries to find a class that is not registered in the mapping context.

Yeah,
So I have (Portfolio)-[:HAS_ASSET]->(Asset)-[:HAS_BUILDING]->(Building)-[:HAS_ADDRESS]->(Address)

I am trying to get my building using UUID and populate Asset and Address of the building.

The query looks like this:

MATCH (b:Building) WHERE b.uuid = $buildingUuid WITH b RETURN b, [(b)-[r1:HAS_ADDRESS]-(addr:Address)|[r1, addr]], [(b)<-[r2:HAS_BUILDING]-(a:Asset)|[r2, a, [[(a)<-[r3:HAS_ASSET]-(p:Portfolio) | [r3, p]]]]] with params {buildingUuid=e1168f32-598a-40b4-b7f5-3be8b2a3c557}

It is a simple REST based application that works okay under low load. AS soon as I send multiple requests at the same time, some calls fail with the error above.

Also experiencing the same (or similar issue).

I am getting an intermittent NPE being thrown when performing a simple read from the database.

It works sometimes and fails other times. I suspect it might be due to some conflict between loaded classes, but I have analysed the dependencies added in the application and cant see the problem.

The stacktrace I am seeing is:

java.lang.NullPointerException
        at org.neo4j.ogm.metadata.MetaData.classInfo(MetaData.java:113)
        at org.neo4j.ogm.context.SingleUseEntityMapper.writeProperty(SingleUseEntityMapper.java:162)
        at org.neo4j.ogm.context.SingleUseEntityMapper.setPropertiesOnEntity(SingleUseEntityMapper.java:111)
        at org.neo4j.ogm.context.SingleUseEntityMapper.map(SingleUseEntityMapper.java:104)
        at org.springframework.data.neo4j.repository.query.CustomResultConverter.convert(CustomResultConverter.java:62)
        at org.springframework.data.repository.query.ResultProcessor$ChainingConverter.convert(ResultProcessor.java:240)
        at org.springframework.data.repository.query.ResultProcessor$ChainingConverter.lambda$and$0(ResultProcessor.java:226)
        at org.springframework.data.repository.query.ResultProcessor$ChainingConverter.convert(ResultProcessor.java:240)
        at org.springframework.data.repository.query.ResultProcessor.processResult(ResultProcessor.java:170)
        at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.doExecute(GraphRepositoryQuery.java:79)
        at org.springframework.data.neo4j.repository.query.AbstractGraphRepositoryQuery.execute(AbstractGraphRepositoryQuery.java:57)
        at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:137)
        at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:121)
        at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:159)
        at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:138)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
        at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
        at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
        at com.sun.proxy.$Proxy182.findByUuid(Unknown Source)

I currently have the dependencies:

  • Spring Boot: 2.5.9 (hope to get to Spring Boot 2.6.3 when this issue is resolved)
  • Java 11 (hope to upgrade to Java 17 this year, but currently limited to Java 11)
  • neo4j-ogm-core: 3.2.28
  • neo4j-ogm-http-driver: 3.2.27
  • neo4j-java-driver: 4.4.0

Just check version compatibility of your installation. If everything compatible is installed then some classes are duplicates and placed in different jars but same package name/class path.So there could be some classes that are duplicates, located in different jars but java class loader is getting ambiguous and may be because of that it is giving null pointer error.
Many thanks
G Sam