title: Spark flatmap is giving Iterator error
body: <p>I am getting error if I apply a flatMap over a JSONArray to JSONObject
  If I am running on my local(laptop) from eclipse, it runs fine, but when running on cluster(YARN), it gives weird error.
  Spark Version 2.0.0 </p>
  
  <p>Code:-</p>
  
  <pre><code>JavaRDD&lt;JSONObject&gt; rdd7 = rdd6.flatMap(new FlatMapFunction&lt;JSONArray, JSONObject&gt;(){
      @Override
      public Iterable&lt;JSONObject&gt; call(JSONArray array) throws Exception {
          List&lt;JSONObject&gt; list = new ArrayList&lt;JSONObject&gt;();
          for (int i = 0; i &lt; array.length();list.add(array.getJSONObject(i++)));             
          return list;
      }
  });
  </code></pre>
  
  <p>error-log:-</p>
  
  <pre><code>java.lang.AbstractMethodError: com.pwc.spark.tifcretrolookup.TIFCRetroJob$2.call(Ljava/lang/Object;)Ljava/util/Iterator;
      at org.apache.spark.api.java.JavaRDDLike$$anonfun$fn$1$1.apply(JavaRDDLike.scala:124)
      at org.apache.spark.api.java.JavaRDDLike$$anonfun$fn$1$1.apply(JavaRDDLike.scala:124)
      at scala.collection.Iterator$$anon$12.nextCur(Iterator.scala:434)
      at scala.collection.Iterator$$anon$12.hasNext(Iterator.scala:440)
      at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:408)
      at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:408)
      at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:408)
      at scala.collection.convert.Wrappers$IteratorWrapper.hasNext(Wrappers.scala:30)
      at com.pwc.spark.ElasticsearchClientLib.CommonESClient.index(CommonESClient.java:33)
      at com.pwc.spark.ElasticsearchClientLib.ESClient.call(ESClient.java:34)
      at com.pwc.spark.ElasticsearchClientLib.ESClient.call(ESClient.java:15)
      at org.apache.spark.api.java.JavaRDDLike$$anonfun$foreachPartition$1.apply(JavaRDDLike.scala:218)
      at org.apache.spark.api.java.JavaRDDLike$$anonfun$foreachPartition$1.apply(JavaRDDLike.scala:218)
      at org.apache.spark.rdd.RDD$$anonfun$foreachPartition$1$$anonfun$apply$28.apply(RDD.scala:883)
      at org.apache.spark.rdd.RDD$$anonfun$foreachPartition$1$$anonfun$apply$28.apply(RDD.scala:883)
      at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:1897)
      at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:1897)
      at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:70)
      at org.apache.spark.scheduler.Task.run(Task.scala:85)
      at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:274)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>