<?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: Nullpointer Exception on broadcast variables (YARN Cluster mode) in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Nullpointer-Exception-on-broadcast-variables-YARN-Cluster/m-p/25312#M5198</link>
    <description>&lt;P&gt;What is null? I don't see you using a broadcast fariable in a closure here. You just put one in a static member, which isn't going to work.&lt;/P&gt;</description>
    <pubDate>Thu, 05 Mar 2015 11:27:45 GMT</pubDate>
    <dc:creator>srowen</dc:creator>
    <dc:date>2015-03-05T11:27:45Z</dc:date>
    <item>
      <title>Nullpointer Exception on broadcast variables (YARN Cluster mode)</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Nullpointer-Exception-on-broadcast-variables-YARN-Cluster/m-p/25311#M5197</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi All &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a simple spark application, where I am trying to broadcast a String type variable on YARN Cluster. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But every time I am trying to access the broadcast-ed variable value , I am getting null within the Task. It will be really helpful, if you guys can suggest, what I am doing wrong here. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;My code is like follows:- &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;public class TestApp implements Serializable{ &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;static Broadcast&amp;lt;String[]&amp;gt;&amp;nbsp;mongoConnectionString; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;public static void main( String[] args ) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{ &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;String mongoBaseURL = args[0]; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SparkConf sparkConf = &amp;nbsp;new SparkConf().setAppName(Constants.appName); &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;JavaSparkContext javaSparkContext = new JavaSparkContext(sparkConf); &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;mongoConnectionString = javaSparkContext.broadcast(args); &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;JavaSQLContext javaSQLContext = new JavaSQLContext(javaSparkContext); &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;JavaSchemaRDD javaSchemaRDD = javaSQLContext.jsonFile(hdfsBaseURL+Constants.hdfsInputDirectoryPath); &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if(javaSchemaRDD!=null){ &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;javaSchemaRDD.registerTempTable("LogAction"); &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;javaSchemaRDD.cache(); &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pageSchemaRDD = javaSQLContext.sql(SqlConstants.getLogActionPage); &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pageSchemaRDD.foreach(new Test()); &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;} &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;} &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;private static class Test implements VoidFunction&amp;lt;Row&amp;gt;{ &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; /** &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;* &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*/ &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private static final long serialVersionUID = 1L; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public void call(Row t) throws Exception { &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // TODO Auto-generated method stub &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; logger.info("mongoConnectionString "+mongoConnectionString.value()); &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; } &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks and Regards &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Samriddha&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 09:23:23 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Nullpointer-Exception-on-broadcast-variables-YARN-Cluster/m-p/25311#M5197</guid>
      <dc:creator>Samriddha</dc:creator>
      <dc:date>2022-09-16T09:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: Nullpointer Exception on broadcast variables (YARN Cluster mode)</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Nullpointer-Exception-on-broadcast-variables-YARN-Cluster/m-p/25312#M5198</link>
      <description>&lt;P&gt;What is null? I don't see you using a broadcast fariable in a closure here. You just put one in a static member, which isn't going to work.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2015 11:27:45 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Nullpointer-Exception-on-broadcast-variables-YARN-Cluster/m-p/25312#M5198</guid>
      <dc:creator>srowen</dc:creator>
      <dc:date>2015-03-05T11:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: Nullpointer Exception on broadcast variables (YARN Cluster mode)</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Nullpointer-Exception-on-broadcast-variables-YARN-Cluster/m-p/25313#M5199</link>
      <description>&lt;P&gt;I am using the broadcast variable within the class Test, which implements the VoidFunction (this is a closure rght ?) , there I am trying to print its value . And the Broadcast variable is coming as null there. Please suggest. Please note, when I am running the program locally , it worked fine.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2015 12:54:13 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Nullpointer-Exception-on-broadcast-variables-YARN-Cluster/m-p/25313#M5199</guid>
      <dc:creator>Samriddha</dc:creator>
      <dc:date>2015-03-05T12:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: Nullpointer Exception on broadcast variables (YARN Cluster mode)</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Nullpointer-Exception-on-broadcast-variables-YARN-Cluster/m-p/25314#M5200</link>
      <description>&lt;P&gt;Yes but it's a member of a class. When the class is instantiated on the remote worker, it is null again. Make the Broadcast a member of the new function you are defining.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2015 13:04:17 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Nullpointer-Exception-on-broadcast-variables-YARN-Cluster/m-p/25314#M5200</guid>
      <dc:creator>srowen</dc:creator>
      <dc:date>2015-03-05T13:04:17Z</dc:date>
    </item>
  </channel>
</rss>

