title: sparkSession/sparkContext can not get hadoop configuration
body: <p>I am running spark 2, hive, hadoop at local machine, and I want to use spark sql to read data from hive table. </p>
  
  <p>It works all fine when I have hadoop running at default <code>hdfs://localhost:9000</code>, but if I change to a different port in core-site.xml:</p>
  
  <pre><code>&lt;name&gt;fs.defaultFS&lt;/name&gt;
  &lt;value&gt;hdfs://localhost:9099&lt;/value&gt;
  </code></pre>
  
  <p>Running a simple sql <code>spark.sql("select * from archive.tcsv3 limit 100").show();</code> in spark-shell will give me the error:</p>
  
  <pre><code>ERROR metastore.RetryingHMSHandler: AlreadyExistsException(message:Database default already exists)
  .....
  From local/147.214.109.160 to localhost:9000 failed on connection exception: java.net.ConnectException: Connection refused;
  .....
  </code></pre>
  
  <p>I get the AlreadyExistsException before, which doesn't seem to influence the result.</p>
  
  <p>I can make it work by creating a new sparkContext:</p>
  
  <pre><code>import org.apache.spark.SparkContext
  import org.apache.spark.sql.SparkSession
  sc.stop()
  var sc = new SparkContext()
  val session = SparkSession.builder().master("local").appName("test").enableHiveSupport().getOrCreate()
  session.sql("show tables").show()
  </code></pre>
  
  <p>My question is, why the initial sparkSession/sparkContext did not get the correct configuration? How can I fix it? Thanks!</p>