title: hbase-spark load data raise NullPointerException Error (scala)
body: <p>I want to load data from HBase by Spark SQL, I use the <code>hbase-spark</code> <a href="https://hbase.apache.org/book.html#_sparksql_dataframes" rel="nofollow noreferrer">official example</a> and it raise <code>NullPointerException</code></p>
  
  <p>My <code>build.sbt</code> file is:</p>
  
  <pre><code>name := "proj_1"
  version := "0.1"
  scalaVersion := "2.11.12"
  libraryDependencies ++= Seq(
      "org.apache.spark" % "spark-core_2.11" % "2.3.1",
      "org.apache.spark" % "spark-sql_2.11" % "2.3.1",
      "org.apache.spark" % "spark-mllib_2.11" % "2.3.1",
      "org.apache.spark" % "spark-streaming_2.11" % "2.3.1",
      "org.apache.spark" % "spark-hive_2.11" % "2.3.1",
      "org.elasticsearch" % "elasticsearch-hadoop" % "6.4.0",
      "org.apache.hadoop" % "hadoop-core" % "2.6.0-mr1-cdh5.15.1",
      "org.apache.hbase" % "hbase" % "2.1.0",
      "org.apache.hbase" % "hbase-server" % "2.1.0",
      "org.apache.hbase" % "hbase-common" % "2.1.0",
      "org.apache.hbase" % "hbase-client" % "2.1.0",
      "org.apache.hbase" % "hbase-spark" % "2.1.0-cdh6.x-SNAPSHOT"
  )
  resolvers += "Cloudera Repository" at "https://repository.cloudera.com/artifactory/cloudera-repos/"
  resolvers += "clojars" at "https://clojars.org/repo"
  resolvers += "conjars" at "http://conjars.org/repo"
  resolvers += "Apache HBase" at "https://repository.apache.org/content/repositories/releases"
  </code></pre>
  
  <p>The wrong code is:</p>
  
  <pre><code>def withCatalog(cat: String): DataFrame = {
      sqlContext
          .read
          .options(Map(HBaseTableCatalog.tableCatalog-&gt;cat))
          .format("org.apache.hadoop.hbase.spark")
          .option("zkUrl", "127.0.0.1:2181/chen_test")
          .load()
  }
  val df = withCatalog(catalog)
  </code></pre>
  
  <p>Exception info is:</p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException
      at org.apache.hadoop.hbase.spark.HBaseRelation.&lt;init&gt; (DefaultSource.scala:139)
      at org.apache.hadoop.hbase.spark.DefaultSource.createRelation(DefaultSource.scala:70)
      at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:340)
      at org.apache.spark.sql.DataFrameReader.loadV1Source(DataFrameReader.scala:239)
      at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:227)
      at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:164)
      at hbase_test$.withCatalog$1(hbase_test.scala:57)
      at hbase_test$.main(hbase_test.scala:59)
      at hbase_test.main(hbase_test.scala)
  </code></pre>
  
  <p>How do I fix it? Can you help me?</p>