<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Trouble running Java Spark Hive Example in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Trouble-running-Java-Spark-Hive-Example/m-p/226524#M72740</link>
    <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/50212/saxofon4.html" nodeid="50212"&gt;@Eric H&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;could you please check the complete class name with the package name &lt;/P&gt;&lt;PRE&gt;--class "org.apache.spark.examples.sql.hive.JavaSparkHiveExample"&lt;/PRE&gt;&lt;P&gt;as that particular class under the package it couldn't reference directly.&lt;/P&gt;&lt;P&gt;Hope this helps !!&lt;/P&gt;</description>
    <pubDate>Tue, 19 Dec 2017 09:28:15 GMT</pubDate>
    <dc:creator>bkosaraju</dc:creator>
    <dc:date>2017-12-19T09:28:15Z</dc:date>
    <item>
      <title>Trouble running Java Spark Hive Example</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Trouble-running-Java-Spark-Hive-Example/m-p/226523#M72739</link>
      <description>&lt;P&gt;I have the following &lt;A href="https://github.com/apache/spark/blob/master/examples/src/main/java/org/apache/spark/examples/sql/hive/JavaSparkHiveExample.java"&gt;Java Spark Hive Example&lt;/A&gt; as can be found on the official apache/spark Github. I have spend a lot of time understanding how to run the example in my Hortonworks Hadoop Sandbox without success.&lt;/P&gt;&lt;P&gt;Currently, I am doing the following:&lt;/P&gt;&lt;UL&gt;
&lt;LI&gt;Importing the &lt;A href="https://github.com/apache/spark/tree/master/examples"&gt;apache/spark examples&lt;/A&gt; as I Maven-project, this is working fine and I am not getting any issues with decencies so no problem here I'll guess.&lt;/LI&gt;&lt;LI&gt;The next step is to prepare the code to run in my Hadoop Sandbox - the issue is starting here, I am probably setting something wrong to being with. This is what I am doing:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Setting the SparkSession to master local, changing spark.sql.warehouse.dir to hive.metastore.uris and set thrift://localhost:9083 (as I can see in the Hive confing in Ambari) as warehouseLocation.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SparkSession spark =SparkSession.builder().appName("Java Spark Hive Example").master("local[*]").config("hive.metastore.uris","thrift://localhost:9083").enableHiveSupport().getOrCreate();&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Then I replace &lt;CODE&gt;spark.sql("LOAD DATA LOCAL INPATH 'examples/src/main/resources/kv1.txt' INTO TABLE src");
&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;with a path to hdfs where I have uploaded kv1.txt:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;spark.sql("LOAD DATA LOCAL INPATH 'hdfs:///tmp/kv1.txt' INTO TABLE src");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The last step is to make the JAR with &lt;CODE&gt;mvn package&lt;/CODE&gt; on the pom.xml - it builds without errors and gives me &lt;STRONG&gt;original-spark-examples_2.11-2.3.0-SNAPSHOT.jar&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I copy the assembly over to the Hadoop Sandbox &lt;CODE&gt;scp -P 2222 ./target/original-spark-examples_2.11-2.3.0-SNAPSHOT.jar root@sandbox.hortonworks.com:/root&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;and use spark-submit to run the code &lt;CODE&gt;/usr/hdp/current/spark2-client/bin/spark-submit --class "JavaSparkHiveExample" --master local ./original-spark-examples_2.11-2.3.0-SNAPSHOT.jar&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;Which return the following error:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;[root@sandbox-hdp ~]#/usr/hdp/current/spark2-client/bin/spark-submit --class"JavaSparkHiveExample"--master local ./original-spark-examples_2.11-2.3.0-SNAPSHOT.jar
java.lang.ClassNotFoundException:JavaSparkHiveExample
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java.lang.Class.forName0(NativeMethod)
        at java.lang.Class.forName(Class.java:348)
        at org.apache.spark.util.Utils$.classForName(Utils.scala:230)
        at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$runMain(SparkSubmit.scala:739)
        at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:180)
        at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:205)
        at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:119)
        at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)[root@sandbox-hdp ~]#&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;..and here I am totally stuck, probably I am missing some steps to prepare the code to run and so on.&lt;/P&gt;&lt;P&gt;I would be &lt;STRONG&gt;very happy&lt;/STRONG&gt; if I could get some help to get this code to run on my Hadoop Sandbox. I was able to run the JavaWordCount.java Spark example just fine but with this one I am totally stuck. Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Complete &lt;A href="https://github.com/apache/spark/blob/master/examples/src/main/java/org/apache/spark/examples/sql/hive/JavaSparkHiveExample.java"&gt;JavaSparkHiveExample.java&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2017 05:15:29 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Trouble-running-Java-Spark-Hive-Example/m-p/226523#M72739</guid>
      <dc:creator>saxofon4</dc:creator>
      <dc:date>2017-12-19T05:15:29Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble running Java Spark Hive Example</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Trouble-running-Java-Spark-Hive-Example/m-p/226524#M72740</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/50212/saxofon4.html" nodeid="50212"&gt;@Eric H&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;could you please check the complete class name with the package name &lt;/P&gt;&lt;PRE&gt;--class "org.apache.spark.examples.sql.hive.JavaSparkHiveExample"&lt;/PRE&gt;&lt;P&gt;as that particular class under the package it couldn't reference directly.&lt;/P&gt;&lt;P&gt;Hope this helps !!&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2017 09:28:15 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Trouble-running-Java-Spark-Hive-Example/m-p/226524#M72740</guid>
      <dc:creator>bkosaraju</dc:creator>
      <dc:date>2017-12-19T09:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble running Java Spark Hive Example</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Trouble-running-Java-Spark-Hive-Example/m-p/226525#M72741</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/15193/bkosaraju.html" nodeid="15193"&gt;@bkosaraju&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;That solved the problem. Many thanks for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2017 16:11:41 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Trouble-running-Java-Spark-Hive-Example/m-p/226525#M72741</guid>
      <dc:creator>saxofon4</dc:creator>
      <dc:date>2017-12-19T16:11:41Z</dc:date>
    </item>
  </channel>
</rss>

