title: Spark SQL - ERROR XJ040
body: <p>I'm trying to use the new features of pyspark.sql. The code I'm running is as follows:</p>
  
  <pre><code>spark = SparkSession.builder.config("spark.sql.warehouse.dir", "file:///C:/tmp").appName("PopularMovies").getOrCreate()
  lines = spark.sparkContext.textFile("...some file...")
  movies = lines.map(...some function...)
  movieDataset = spark.createDataFrame(movies)
  </code></pre>
  
  <p>It was working perfectly but all of a sudden when running this operation a second time in interactive mode I've started receiving an ERROR XJ040:</p>
  
  <pre><code>Caused by: ERROR XJ040: Failed to start database 'metastore_db' with class loader org.apache.spark.sql.hive.client.IsolatedClientLoader$$anon$1@6b669cdf, see the next exception for details.
      at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
      at org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(Unknown Source)
      ... 97 more
  </code></pre>
  
  <p>Caused by: ERROR XSDB6: Another instance of Derby may have already booted the database C:\Users\giovanni.bruner\metastore_db.</p>
  
  <p>Anyone got any idea how this could be resolved? Restarting the command prompt or even the machine didn't change the situation. </p>