title: java.lang.NoSuchMethodError: org.apache.spark.streaming.api.java.JavaDStream.foreachRDD(Lorg/apache/spark/api/java/function/Function;)V
body: <p>I'm working with kafka-sparkstreaming, java.
  zookeer: v3.3.6, kafka: v2.11-0.10.1.0, spark: v2.0.1-bin-hadoop2.7, scala: v2.11.8.</p>
  
  <p>There were no configuration's done apart from renaming few files in conf directory.</p>
  
  <p>Code to read from kafka:</p>
  
  <pre><code>JavaPairInputDStream&lt;String, String&gt; kafkaStream =
                  KafkaUtils.createDirectStream(jssc, 
                          String.class,
                          String.class,
                          StringDecoder.class,
                          StringDecoder.class,
                          kafkaParams,
                          topicsSet);
  
          JavaDStream&lt;String&gt; data = kafkaStream.map(new Function&lt;Tuple2&lt;String, String&gt;, String&gt;() {
              /**
               * 
               */
              private static final long serialVersionUID = 1L;
  
              public String call(Tuple2&lt;String, String&gt; message) {
                  return message._2();
              }
          });
  
          data.foreachRDD(new Function&lt;JavaRDD&lt;String&gt;, Void&gt;() {
  
              /**
               * 
               */
              private static final long serialVersionUID = 1L;
  
              public Void call(JavaRDD&lt;String&gt; data) throws Exception {
  
                  if(data != null){
                      List&lt;String&gt; result = data.collect();
  
                      for (String jString : result) {
                          System.out.println("========&gt; " + jString);
                      }
                  }else {
                      System.out.println("Got no data in this window");
                  }
                  return null;
              }
          });
  </code></pre>
  
  <p>pom.xml:</p>
  
  <pre><code>&lt;dependency&gt;
              &lt;groupId&gt;org.apache.spark&lt;/groupId&gt;
              &lt;artifactId&gt;spark-streaming_2.11&lt;/artifactId&gt;
              &lt;version&gt;1.5.2&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- https://mvnrepository.com/artifact/org.apache.spark/spark-streaming-kafka_2.10 --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.spark&lt;/groupId&gt;
              &lt;artifactId&gt;spark-streaming-kafka_2.11&lt;/artifactId&gt;
              &lt;version&gt;1.6.2&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- https://mvnrepository.com/artifact/org.apache.kafka/kafka_2.11 --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.kafka&lt;/groupId&gt;
              &lt;artifactId&gt;kafka_2.11&lt;/artifactId&gt;
              &lt;version&gt;0.8.2.1&lt;/version&gt;
          &lt;/dependency&gt;
  
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.scala-lang&lt;/groupId&gt;
              &lt;artifactId&gt;scala-library&lt;/artifactId&gt;
              &lt;version&gt;2.11.1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.spark&lt;/groupId&gt;
              &lt;artifactId&gt;spark-core_2.11&lt;/artifactId&gt;
              &lt;version&gt;1.5.2&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- https://mvnrepository.com/artifact/org.json/json --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.json&lt;/groupId&gt;
              &lt;artifactId&gt;json&lt;/artifactId&gt;
              &lt;version&gt;20160810&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- https://mvnrepository.com/artifact/org.json4s/json4s-ast_2.11 --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.json4s&lt;/groupId&gt;
              &lt;artifactId&gt;json4s-ast_2.11&lt;/artifactId&gt;
              &lt;version&gt;3.2.11&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-common --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.hadoop&lt;/groupId&gt;
              &lt;artifactId&gt;hadoop-common&lt;/artifactId&gt;
              &lt;version&gt;2.2.0&lt;/version&gt;
          &lt;/dependency&gt;
  
  
          &lt;!--&lt;dependency&gt; &lt;groupId&gt;org.apache.storm&lt;/groupId&gt; &lt;artifactId&gt;storm-hdfs&lt;/artifactId&gt; 
              &lt;version&gt;0.10.0-beta1&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.solr&lt;/groupId&gt; 
              &lt;artifactId&gt;solr-solrj&lt;/artifactId&gt; &lt;version&gt;5.3.1&lt;/version&gt; &lt;/dependency&gt; --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.mongodb&lt;/groupId&gt;
              &lt;artifactId&gt;mongo-java-driver&lt;/artifactId&gt;
              &lt;version&gt;3.0.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.googlecode.json-simple&lt;/groupId&gt;
              &lt;artifactId&gt;json-simple&lt;/artifactId&gt;
              &lt;version&gt;1.1&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>The above piece of code was successful in Windows. But, in Linux i'm getting the following error:</p>
  
  <pre><code>[INFO] main 2016-11-23 11:46:16,985 VerifiableProperties info - Verifying properties
  [INFO] main 2016-11-23 11:46:16,987 VerifiableProperties info - Property group.id is overridden to
  [INFO] main 2016-11-23 11:46:16,987 VerifiableProperties info - Property zookeeper.connect is overridden to
  [DEBUG] main 2016-11-23 11:46:17,046 SimpleConsumer debug - Disconnecting from localhost:9092
  [DEBUG] main 2016-11-23 11:46:17,049 BlockingChannel debug - Created socket with SO_TIMEOUT = 30000 (requested 30000), SO_RCVBUF = 65536 (requested 65536), SO_SNDBUF = 1313280 (requested -1), connectTimeoutMs = 30000.
  [DEBUG] main 2016-11-23 11:46:17,079 SimpleConsumer debug - Disconnecting from localhost:9092
  [DEBUG] main 2016-11-23 11:46:17,084 SimpleConsumer debug - Disconnecting from localhost:9092
  [DEBUG] main 2016-11-23 11:46:17,084 BlockingChannel debug - Created socket with SO_TIMEOUT = 30000 (requested 30000), SO_RCVBUF = 65536 (requested 65536), SO_SNDBUF = 1313280 (requested -1), connectTimeoutMs = 30000.
  [DEBUG] main 2016-11-23 11:46:17,086 SimpleConsumer debug - Disconnecting from localhost:9092
  [DEBUG] main 2016-11-23 11:46:17,094 SimpleConsumer debug - Disconnecting from mc4:9092
  [DEBUG] main 2016-11-23 11:46:17,095 BlockingChannel debug - Created socket with SO_TIMEOUT = 30000 (requested 30000), SO_RCVBUF = 65536 (requested 65536), SO_SNDBUF = 1313280 (requested -1), connectTimeoutMs = 30000.
  [DEBUG] main 2016-11-23 11:46:17,106 SimpleConsumer debug - Disconnecting from mc4:9092
  [DEBUG] main 2016-11-23 11:46:17,286 ClosureCleaner logDebug - +++ Cleaning closure &lt;function1&gt; (org.apache.spark.api.java.JavaPairRDD$$anonfun$toScalaFunction$1) +++
  [DEBUG] main 2016-11-23 11:46:17,302 ClosureCleaner logDebug -  + declared fields: 2
  [DEBUG] main 2016-11-23 11:46:17,303 ClosureCleaner logDebug -      public static final long org.apache.spark.api.java.JavaPairRDD$$anonfun$toScalaFunction$1.serialVersionUID
  [DEBUG] main 2016-11-23 11:46:17,303 ClosureCleaner logDebug -      private final org.apache.spark.api.java.function.Function org.apache.spark.api.java.JavaPairRDD$$anonfun$toScalaFunction$1.fun$1
  [DEBUG] main 2016-11-23 11:46:17,303 ClosureCleaner logDebug -  + declared methods: 1
  [DEBUG] main 2016-11-23 11:46:17,304 ClosureCleaner logDebug -      public final java.lang.Object org.apache.spark.api.java.JavaPairRDD$$anonfun$toScalaFunction$1.apply(java.lang.Object)
  [DEBUG] main 2016-11-23 11:46:17,304 ClosureCleaner logDebug -  + inner classes: 0
  [DEBUG] main 2016-11-23 11:46:17,305 ClosureCleaner logDebug -  + outer classes: 0
  [DEBUG] main 2016-11-23 11:46:17,306 ClosureCleaner logDebug -  + outer objects: 0
  [DEBUG] main 2016-11-23 11:46:17,308 ClosureCleaner logDebug -  + populating accessed fields because this is the starting closure
  [DEBUG] main 2016-11-23 11:46:17,311 ClosureCleaner logDebug -  + fields accessed by starting closure: 0
  [DEBUG] main 2016-11-23 11:46:17,312 ClosureCleaner logDebug -  + there are no enclosing objects!
  [DEBUG] main 2016-11-23 11:46:17,313 ClosureCleaner logDebug -  +++ closure &lt;function1&gt; (org.apache.spark.api.java.JavaPairRDD$$anonfun$toScalaFunction$1) is now cleaned +++
  [ERROR] main 2016-11-23 11:46:17,320 root flush - Exception in thread "main"
  [ERROR] main 2016-11-23 11:46:17,320 root flush - java.lang.NoSuchMethodError: org.apache.spark.streaming.api.java.JavaDStream.foreachRDD(Lorg/apache/spark/api/java/function/Function;)V
  [ERROR] main 2016-11-23 11:46:17,320 root flush -       at org.labs.spark.streaming.StreamingKafkaConsumer.run(StreamingKafkaConsumer.java:87)
  [ERROR] main 2016-11-23 11:46:17,320 root flush -       at org.labs.spark.streaming.StreamingApi.main(StreamingApi.java:35)
  [ERROR] main 2016-11-23 11:46:17,320 root flush -       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  [ERROR] main 2016-11-23 11:46:17,320 root flush -       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  [ERROR] main 2016-11-23 11:46:17,320 root flush -       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  [ERROR] main 2016-11-23 11:46:17,320 root flush -       at java.lang.reflect.Method.invoke(Method.java:498)
  [ERROR] main 2016-11-23 11:46:17,320 root flush -       at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:736)
  [ERROR] main 2016-11-23 11:46:17,320 root flush -       at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:185)
  [ERROR] main 2016-11-23 11:46:17,320 root flush -       at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:210)
  [ERROR] main 2016-11-23 11:46:17,320 root flush -       at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:124)
  [ERROR] main 2016-11-23 11:46:17,321 root flush -       at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
  [INFO] Thread-1 2016-11-23 11:46:17,327 SparkContext logInfo - Invoking stop() from shutdown hook
  </code></pre>
  
  <p>I have tried changing kafka version to 2.10-0.10.1.0 and 2.9.2-0.8.1.1 too. But couldn't get through.</p>