java.util.NoSuchElementException

Spring JIRA | Mark Spritzler | 5 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    I have a User object with a Set<User> friends mapped with relationship User.FRIEND which is a constant "FRIEND", set as Direction.both. I want to run a query where I get back only friends of friends in a list. If a friend doesn't have any friends, then that friend returns nothing. In the end, if I have no friends or no friends of friends, then I should get an empty List in my Page object. I have tried other versions of this query with [?:" + User.FRIEND+"], with -> for changing direction in the query, and no luck. {CODE} @Query("start user=node({0}) " + "match user-[:"+ User.FRIEND+"]-friends-[:"+ User.FRIEND+"]-friendsOfFriends " + "return friendsOfFriends " + "order by count(*) desc") public Page<User> findFriendsOfFriends(User user, Pageable pageable); {CODE} Exception that that query causes {CODE} java.util.NoSuchElementException at scala.collection.TraversableLike$$anonfun$2.apply(TraversableLike.scala:372) at scala.collection.TraversableLike$$anonfun$2.apply(TraversableLike.scala:372) at scala.collection.TraversableLike$class.head(TraversableLike.scala:379) at org.neo4j.cypher.pipes.Pipe.head(Pipe.scala:31) at org.neo4j.cypher.pipes.SlicePipe.foreach(SlicePipe.scala:30) at org.neo4j.cypher.pipes.ColumnFilterPipe.foreach(ColumnFilterPipe.scala:35) at scala.collection.TraversableLike$class.map(TraversableLike.scala:194) at org.neo4j.cypher.pipes.Pipe.map(Pipe.scala:31) at org.neo4j.cypher.ExecutionResult$class.javaIterator(ExecutionResult.scala:49) at org.neo4j.cypher.pipes.ColumnFilterPipe.javaIterator(ColumnFilterPipe.scala:25) at org.neo4j.cypher.javacompat.ExecutionResult.iterator(ExecutionResult.java:51) at org.springframework.data.neo4j.conversion.QueryResultBuilder$1.iterator(QueryResultBuilder.java:112) at org.neo4j.helpers.collection.IteratorUtil.addToCollection(IteratorUtil.java:339) at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.createPage(GraphRepositoryQuery.java:107) at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.dispatchQuery(GraphRepositoryQuery.java:88) at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:70) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:301) 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 $Proxy50.findFriendsOfFriends(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196) at $Proxy52.findFriendsOfFriends(Unknown Source) at com.perfectworldprogramming.eventgate.user.UserDBTests.testFindFriendsOfFriends(UserDBTests.java:155) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.junit.runner.JUnitCore.run(JUnitCore.java:157) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) {CODE}

    Spring JIRA | 5 years ago | Mark Spritzler
    java.util.NoSuchElementException
  2. 0

    I have a User object with a Set<User> friends mapped with relationship User.FRIEND which is a constant "FRIEND", set as Direction.both. I want to run a query where I get back only friends of friends in a list. If a friend doesn't have any friends, then that friend returns nothing. In the end, if I have no friends or no friends of friends, then I should get an empty List in my Page object. I have tried other versions of this query with [?:" + User.FRIEND+"], with -> for changing direction in the query, and no luck. {CODE} @Query("start user=node({0}) " + "match user-[:"+ User.FRIEND+"]-friends-[:"+ User.FRIEND+"]-friendsOfFriends " + "return friendsOfFriends " + "order by count(*) desc") public Page<User> findFriendsOfFriends(User user, Pageable pageable); {CODE} Exception that that query causes {CODE} java.util.NoSuchElementException at scala.collection.TraversableLike$$anonfun$2.apply(TraversableLike.scala:372) at scala.collection.TraversableLike$$anonfun$2.apply(TraversableLike.scala:372) at scala.collection.TraversableLike$class.head(TraversableLike.scala:379) at org.neo4j.cypher.pipes.Pipe.head(Pipe.scala:31) at org.neo4j.cypher.pipes.SlicePipe.foreach(SlicePipe.scala:30) at org.neo4j.cypher.pipes.ColumnFilterPipe.foreach(ColumnFilterPipe.scala:35) at scala.collection.TraversableLike$class.map(TraversableLike.scala:194) at org.neo4j.cypher.pipes.Pipe.map(Pipe.scala:31) at org.neo4j.cypher.ExecutionResult$class.javaIterator(ExecutionResult.scala:49) at org.neo4j.cypher.pipes.ColumnFilterPipe.javaIterator(ColumnFilterPipe.scala:25) at org.neo4j.cypher.javacompat.ExecutionResult.iterator(ExecutionResult.java:51) at org.springframework.data.neo4j.conversion.QueryResultBuilder$1.iterator(QueryResultBuilder.java:112) at org.neo4j.helpers.collection.IteratorUtil.addToCollection(IteratorUtil.java:339) at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.createPage(GraphRepositoryQuery.java:107) at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.dispatchQuery(GraphRepositoryQuery.java:88) at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:70) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:301) 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 $Proxy50.findFriendsOfFriends(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196) at $Proxy52.findFriendsOfFriends(Unknown Source) at com.perfectworldprogramming.eventgate.user.UserDBTests.testFindFriendsOfFriends(UserDBTests.java:155) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.junit.runner.JUnitCore.run(JUnitCore.java:157) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) {CODE}

    Spring JIRA | 5 years ago | Mark Spritzler
    java.util.NoSuchElementException

    Root Cause Analysis

    1. java.util.NoSuchElementException

      No message provided

      at scala.collection.TraversableLike$$anonfun$2.apply()
    2. Scala
      TraversableLike$class.head
      1. scala.collection.TraversableLike$$anonfun$2.apply(TraversableLike.scala:372)
      2. scala.collection.TraversableLike$$anonfun$2.apply(TraversableLike.scala:372)
      3. scala.collection.TraversableLike$class.head(TraversableLike.scala:379)
      3 frames
    3. org.neo4j.cypher
      ColumnFilterPipe.foreach
      1. org.neo4j.cypher.pipes.Pipe.head(Pipe.scala:31)
      2. org.neo4j.cypher.pipes.SlicePipe.foreach(SlicePipe.scala:30)
      3. org.neo4j.cypher.pipes.ColumnFilterPipe.foreach(ColumnFilterPipe.scala:35)
      3 frames
    4. Scala
      TraversableLike$class.map
      1. scala.collection.TraversableLike$class.map(TraversableLike.scala:194)
      1 frame
    5. org.neo4j.cypher
      Pipe.map
      1. org.neo4j.cypher.pipes.Pipe.map(Pipe.scala:31)
      1 frame
    6. Neo4j - Cypher
      ExecutionResult$class.javaIterator
      1. org.neo4j.cypher.ExecutionResult$class.javaIterator(ExecutionResult.scala:49)
      1 frame
    7. org.neo4j.cypher
      ColumnFilterPipe.javaIterator
      1. org.neo4j.cypher.pipes.ColumnFilterPipe.javaIterator(ColumnFilterPipe.scala:25)
      1 frame
    8. Neo4j - Cypher
      ExecutionResult.iterator
      1. org.neo4j.cypher.javacompat.ExecutionResult.iterator(ExecutionResult.java:51)
      1 frame
    9. Spring Data Neo4j
      QueryResultBuilder$1.iterator
      1. org.springframework.data.neo4j.conversion.QueryResultBuilder$1.iterator(QueryResultBuilder.java:112)
      1 frame
    10. Neo4j - Graph Database Kernel
      IteratorUtil.addToCollection
      1. org.neo4j.helpers.collection.IteratorUtil.addToCollection(IteratorUtil.java:339)
      1 frame
    11. Spring Data Neo4j
      GraphRepositoryQuery.execute
      1. org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.createPage(GraphRepositoryQuery.java:107)
      2. org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.dispatchQuery(GraphRepositoryQuery.java:88)
      3. org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:70)
      3 frames
    12. Spring Data Core
      RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke
      1. org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:301)
      1 frame
    13. Spring AOP
      ReflectiveMethodInvocation.proceed
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      1 frame
    14. Spring Tx
      TransactionInterceptor.invoke
      1. org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
      1 frame
    15. Spring AOP
      ReflectiveMethodInvocation.proceed
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      1 frame
    16. Spring Tx
      PersistenceExceptionTranslationInterceptor.invoke
      1. org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
      1 frame
    17. Spring AOP
      JdkDynamicAopProxy.invoke
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      2 frames
    18. Unknown
      $Proxy50.findFriendsOfFriends
      1. $Proxy50.findFriendsOfFriends(Unknown Source)
      1 frame
    19. Java RT
      DelegatingMethodAccessorImpl.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      3 frames
    20. Spring AOP
      JdkDynamicAopProxy.invoke
      1. org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
      2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196)
      2 frames
    21. Unknown
      $Proxy52.findFriendsOfFriends
      1. $Proxy52.findFriendsOfFriends(Unknown Source)
      1 frame
    22. com.perfectworldprogramming.eventgate
      UserDBTests.testFindFriendsOfFriends
      1. com.perfectworldprogramming.eventgate.user.UserDBTests.testFindFriendsOfFriends(UserDBTests.java:155)
      1 frame
    23. Java RT
      DelegatingMethodAccessorImpl.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      3 frames
    24. JUnit
      RunBefores.evaluate
      1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
      2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
      4. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      5. org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
      5 frames
    25. Spring TestContext
      SpringJUnit4ClassRunner.runChild
      1. org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
      2. org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
      3. org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
      4. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
      4 frames
    26. JUnit
      ParentRunner$2.evaluate
      1. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
      2. org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
      3. org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
      4. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
      5. org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
      6. org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
      6 frames
    27. Spring TestContext
      RunAfterTestClassCallbacks.evaluate
      1. org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      2. org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
      2 frames
    28. JUnit
      ParentRunner.run
      1. org.junit.runners.ParentRunner.run(ParentRunner.java:236)
      1 frame
    29. Spring TestContext
      SpringJUnit4ClassRunner.run
      1. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
      1 frame
    30. JUnit
      JUnitCore.run
      1. org.junit.runner.JUnitCore.run(JUnitCore.java:157)
      1 frame
    31. IntelliJ junit4 module
      JUnit4IdeaTestRunner.startRunnerWithArgs
      1. com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71)
      1 frame
    32. IDEA
      JUnitStarter.main
      1. com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
      2. com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
      2 frames
    33. Java RT
      NativeMethodAccessorImpl.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      2 frames
    34. IDEA
      AppMain.main
      1. com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
      1 frame