java.util.NoSuchElementException: next on empty iterator

JIRA | Evert Lammerts | 2 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    calling parquetFile (in the sparkr-sql branch) fails with: {code:none} > parquetFile(sqlCtx, path) parquetFile on 2 failed with java.util.NoSuchElementException: next on empty iterator java.util.NoSuchElementException: next on empty iterator at scala.collection.Iterator$$anon$2.next(Iterator.scala:39) at scala.collection.Iterator$$anon$2.next(Iterator.scala:37) at scala.collection.IndexedSeqLike$Elements.next(IndexedSeqLike.scala:64) at scala.collection.IterableLike$class.head(IterableLike.scala:91) at scala.collection.mutable.ArrayOps$ofRef.scala$collection$IndexedSeqOptimized$$super$head(ArrayOps.scala:108) at scala.collection.IndexedSeqOptimized$class.head(IndexedSeqOptimized.scala:120) at scala.collection.mutable.ArrayOps$ofRef.head(ArrayOps.scala:108) at edu.berkeley.cs.amplab.sparkr.SparkRBackendHandler.handleMethodCall(SparkRBackendHandler.scala:111) at edu.berkeley.cs.amplab.sparkr.SparkRBackendHandler.channelRead0(SparkRBackendHandler.scala:60) at edu.berkeley.cs.amplab.sparkr.SparkRBackendHandler.channelRead0(SparkRBackendHandler.scala:22) {code} This is caused by edu.berkeley.cs.amplab.sparkr.SparkRBackendHandler#matchMethod. It tries to find a method with signature org.apache.spark.sql.SQLContext.parquetFile(java.lang.String), but only org.apache.spark.sql.SQLContext.parquetFile(java.lang.String...) exists (varargs argument). There are three ways of fixing this: # change the parquetFile signature in SQLContext.R # change edu.berkeley.cs.amplab.sparkr.SparkRBackendHandler#matchMethod to handle matching of varargs arguments # change org.apache.spark.sql.SQLContext.parquetFile signature to a single String There's something to say for option 3, because jsonFiledoesn't have a varargs signature either. It's a breaking change though. Option 2 should be done anyway, I guess. I believe this is the most simple solution, but I'm not sure how to go about it. Maybe check both for signatures of type T and type T[]. Any ideas? For an easy fix, option 1 is most suitable. I'll put in a pull request of code that I've tested and that works for me.

    JIRA | 2 years ago | Evert Lammerts
    java.util.NoSuchElementException: next on empty iterator
  2. 0

    calling parquetFile (in the sparkr-sql branch) fails with: {code:none} > parquetFile(sqlCtx, path) parquetFile on 2 failed with java.util.NoSuchElementException: next on empty iterator java.util.NoSuchElementException: next on empty iterator at scala.collection.Iterator$$anon$2.next(Iterator.scala:39) at scala.collection.Iterator$$anon$2.next(Iterator.scala:37) at scala.collection.IndexedSeqLike$Elements.next(IndexedSeqLike.scala:64) at scala.collection.IterableLike$class.head(IterableLike.scala:91) at scala.collection.mutable.ArrayOps$ofRef.scala$collection$IndexedSeqOptimized$$super$head(ArrayOps.scala:108) at scala.collection.IndexedSeqOptimized$class.head(IndexedSeqOptimized.scala:120) at scala.collection.mutable.ArrayOps$ofRef.head(ArrayOps.scala:108) at edu.berkeley.cs.amplab.sparkr.SparkRBackendHandler.handleMethodCall(SparkRBackendHandler.scala:111) at edu.berkeley.cs.amplab.sparkr.SparkRBackendHandler.channelRead0(SparkRBackendHandler.scala:60) at edu.berkeley.cs.amplab.sparkr.SparkRBackendHandler.channelRead0(SparkRBackendHandler.scala:22) {code} This is caused by edu.berkeley.cs.amplab.sparkr.SparkRBackendHandler#matchMethod. It tries to find a method with signature org.apache.spark.sql.SQLContext.parquetFile(java.lang.String), but only org.apache.spark.sql.SQLContext.parquetFile(java.lang.String...) exists (varargs argument). There are three ways of fixing this: # change the parquetFile signature in SQLContext.R # change edu.berkeley.cs.amplab.sparkr.SparkRBackendHandler#matchMethod to handle matching of varargs arguments # change org.apache.spark.sql.SQLContext.parquetFile signature to a single String There's something to say for option 3, because jsonFiledoesn't have a varargs signature either. It's a breaking change though. Option 2 should be done anyway, I guess. I believe this is the most simple solution, but I'm not sure how to go about it. Maybe check both for signatures of type T and type T[]. Any ideas? For an easy fix, option 1 is most suitable. I'll put in a pull request of code that I've tested and that works for me.

    JIRA | 2 years ago | Evert Lammerts
    java.util.NoSuchElementException: next on empty iterator
  3. 0

    Uninformative exception when `head` called on empty list

    GitHub | 4 years ago | schmmd
    java.util.NoSuchElementException: next on empty iterator
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Error parsing application/x-www-form-urlencoded

    GitHub | 3 years ago | nuaadupuliu
    java.util.NoSuchElementException: next on empty iterator

  1. rp 6 times, last 1 year ago
2 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.util.NoSuchElementException

    next on empty iterator

    at scala.collection.Iterator$$anon$2.next()
  2. Scala
    ArrayOps$ofRef.head
    1. scala.collection.Iterator$$anon$2.next(Iterator.scala:39)
    2. scala.collection.Iterator$$anon$2.next(Iterator.scala:37)
    3. scala.collection.IndexedSeqLike$Elements.next(IndexedSeqLike.scala:64)
    4. scala.collection.IterableLike$class.head(IterableLike.scala:91)
    5. scala.collection.mutable.ArrayOps$ofRef.scala$collection$IndexedSeqOptimized$$super$head(ArrayOps.scala:108)
    6. scala.collection.IndexedSeqOptimized$class.head(IndexedSeqOptimized.scala:120)
    7. scala.collection.mutable.ArrayOps$ofRef.head(ArrayOps.scala:108)
    7 frames
  3. edu.berkeley.cs
    SparkRBackendHandler.channelRead0
    1. edu.berkeley.cs.amplab.sparkr.SparkRBackendHandler.handleMethodCall(SparkRBackendHandler.scala:111)
    2. edu.berkeley.cs.amplab.sparkr.SparkRBackendHandler.channelRead0(SparkRBackendHandler.scala:60)
    3. edu.berkeley.cs.amplab.sparkr.SparkRBackendHandler.channelRead0(SparkRBackendHandler.scala:22)
    3 frames