java.lang.NullPointerException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • From Craig Giordano: {code} I am using SDN 2.1.0.BUILD-SNAPSHOT and Neo4j 1.7. I have modeled an Activity that has an activityCode and a time range containing a begin and end date. I need to find the Activity with the latest begin date. At first I thought, just write a cypher query returning the Activity and begin date as a @MapResult sorting by begin date DESC and grab the first one from the list. This works fine. When there are no Activity's I get an empty list back as expected. Then I thought, a list is silly when I am only interested in the first item so I decided to try the LIMIT key word, ending my query with LIMIT 1. I changed the signature of my method to return a @MapResult instead of a List and it worked. Except for the case where there are no satisfying Activity's. Instead of returning null, I get a NullPointException as follows: java.lang.NullPointerException at org.springframework.data.neo4j.support.conversion.EntityResultConverter.extractMapResult(EntityResultConverter.java:85) at org.springframework.data.neo4j.support.conversion.EntityResultConverter.convert(EntityResultConverter.java:97) at org.springframework.data.neo4j.conversion.QueryResultBuilder$1.convert(QueryResultBuilder.java:102) at org.springframework.data.neo4j.conversion.QueryResultBuilder$1.singleOrNull(QueryResultBuilder.java:95) at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.dispatchQuery(GraphRepositoryQuery.java:96) at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:70) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:313) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy35.findWithLatestBeginByActivityCodeAndTimeRange(Unknown Source) at com.ierin.paragon2.domain.repository.ActivityRepositoryTest.canFindActivityByActivityCodeAndTimeRange_BadActivityCode(ActivityRepositoryTest.java:65) To show some specifics here are two methods with the same cypher query but different behavior when the results are zero: @Query("start activity=node:DATA_SET_ID_INDEX(dataSetId = {scheduleDataSetId}) " + "match activity-[:MODEL_SCHEDULE_ACTIVITY]->plantVariable, activity-[:timeRange]->t " + "where plantVariable.dataSetId = {modelDataSetId} " + "and activity.activityCode = {activityCode} " + "and t.begin < {end} " + "and (t.end? is null or t.end > {begin}) " + "return activity, t.begin as beginDate order by beginDate desc limit 1") ActivityBeginDateResult findWithLatestBeginByActivityCodeAndTimeRange(@Param("modelDataSetId") String modelDataSetId, @Param("scheduleDataSetId") String scheduleDataSetId, @Param("activityCode") String activityCode, @Param("begin") Long begin, @Param("end") Long end); @Query("start activity=node:DATA_SET_ID_INDEX(dataSetId = {scheduleDataSetId}) " + "match activity-[:MODEL_SCHEDULE_ACTIVITY]->plantVariable, activity-[:timeRange]->t " + "where plantVariable.dataSetId = {modelDataSetId} " + "and activity.activityCode = {activityCode} " + "and t.begin < {end} " + "and (t.end? is null or t.end > {begin}) " + "return activity, t.begin as beginDate order by beginDate desc limit 1") List<ActivityBeginDateResult> findWithLatestBeginByActivityCodeAndTimeRangeInList(@Param("modelDataSetId") String modelDataSetId, @Param("scheduleDataSetId") String scheduleDataSetId, @Param("activityCode") String activityCode, @Param("begin") Long begin, @Param("end") Long end); The first method throws the NullPointerException while the second returns an empty List. Is this a bug or am I misusing the API? Thanks, Craig {code}
    via by Lasse Westh-Nielsen,
  • From Craig Giordano: {code} I am using SDN 2.1.0.BUILD-SNAPSHOT and Neo4j 1.7. I have modeled an Activity that has an activityCode and a time range containing a begin and end date. I need to find the Activity with the latest begin date. At first I thought, just write a cypher query returning the Activity and begin date as a @MapResult sorting by begin date DESC and grab the first one from the list. This works fine. When there are no Activity's I get an empty list back as expected. Then I thought, a list is silly when I am only interested in the first item so I decided to try the LIMIT key word, ending my query with LIMIT 1. I changed the signature of my method to return a @MapResult instead of a List and it worked. Except for the case where there are no satisfying Activity's. Instead of returning null, I get a NullPointException as follows: java.lang.NullPointerException at org.springframework.data.neo4j.support.conversion.EntityResultConverter.extractMapResult(EntityResultConverter.java:85) at org.springframework.data.neo4j.support.conversion.EntityResultConverter.convert(EntityResultConverter.java:97) at org.springframework.data.neo4j.conversion.QueryResultBuilder$1.convert(QueryResultBuilder.java:102) at org.springframework.data.neo4j.conversion.QueryResultBuilder$1.singleOrNull(QueryResultBuilder.java:95) at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.dispatchQuery(GraphRepositoryQuery.java:96) at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:70) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:313) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy35.findWithLatestBeginByActivityCodeAndTimeRange(Unknown Source) at com.ierin.paragon2.domain.repository.ActivityRepositoryTest.canFindActivityByActivityCodeAndTimeRange_BadActivityCode(ActivityRepositoryTest.java:65) To show some specifics here are two methods with the same cypher query but different behavior when the results are zero: @Query("start activity=node:DATA_SET_ID_INDEX(dataSetId = {scheduleDataSetId}) " + "match activity-[:MODEL_SCHEDULE_ACTIVITY]->plantVariable, activity-[:timeRange]->t " + "where plantVariable.dataSetId = {modelDataSetId} " + "and activity.activityCode = {activityCode} " + "and t.begin < {end} " + "and (t.end? is null or t.end > {begin}) " + "return activity, t.begin as beginDate order by beginDate desc limit 1") ActivityBeginDateResult findWithLatestBeginByActivityCodeAndTimeRange(@Param("modelDataSetId") String modelDataSetId, @Param("scheduleDataSetId") String scheduleDataSetId, @Param("activityCode") String activityCode, @Param("begin") Long begin, @Param("end") Long end); @Query("start activity=node:DATA_SET_ID_INDEX(dataSetId = {scheduleDataSetId}) " + "match activity-[:MODEL_SCHEDULE_ACTIVITY]->plantVariable, activity-[:timeRange]->t " + "where plantVariable.dataSetId = {modelDataSetId} " + "and activity.activityCode = {activityCode} " + "and t.begin < {end} " + "and (t.end? is null or t.end > {begin}) " + "return activity, t.begin as beginDate order by beginDate desc limit 1") List<ActivityBeginDateResult> findWithLatestBeginByActivityCodeAndTimeRangeInList(@Param("modelDataSetId") String modelDataSetId, @Param("scheduleDataSetId") String scheduleDataSetId, @Param("activityCode") String activityCode, @Param("begin") Long begin, @Param("end") Long end); The first method throws the NullPointerException while the second returns an empty List. Is this a bug or am I misusing the API? Thanks, Craig {code}
    via by Lasse Westh-Nielsen,
    • java.lang.NullPointerException at org.springframework.data.neo4j.support.conversion.EntityResultConverter.extractMapResult(EntityResultConverter.java:85) at org.springframework.data.neo4j.support.conversion.EntityResultConverter.convert(EntityResultConverter.java:97) at org.springframework.data.neo4j.conversion.QueryResultBuilder$1.convert(QueryResultBuilder.java:102) at org.springframework.data.neo4j.conversion.QueryResultBuilder$1.singleOrNull(QueryResultBuilder.java:95) at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.dispatchQuery(GraphRepositoryQuery.java:96) at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:70) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:313) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy35.findWithLatestBeginByActivityCodeAndTimeRange(Unknown Source) at com.ierin.paragon2.domain.repository.ActivityRepositoryTest.canFindActivityByActivityCodeAndTimeRange_BadActivityCode(ActivityRepositoryTest.java:65)
    No Bugmate found.