title: Failed to find data source: com.mongodb.spark.sql.DefaultSource
body: <p>I'm trying to connect spark (pyspark) to mongodb as follows:</p>
  
  <pre><code>conf = SparkConf()
  conf.set('spark.mongodb.input.uri', default_mongo_uri)
  conf.set('spark.mongodb.output.uri', default_mongo_uri)
  sc = SparkContext(conf=conf)
  sqlContext = SQLContext(sc)
  spark = SparkSession \
      .builder \
      .appName("my-app") \
      .config("spark.mongodb.input.uri", default_mongo_uri) \
      .config("spark.mongodb.output.uri", default_mongo_uri) \
      .getOrCreate()
  </code></pre>
  
  <p>But when I do the following:</p>
  
  <pre><code>users = spark.read.format("com.mongodb.spark.sql.DefaultSource") \
          .option("uri", '{uri}.{col}'.format(uri=mongo_uri, col='users')).load()
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>java.lang.ClassNotFoundException: Failed to find data source:
    com.mongodb.spark.sql.DefaultSource</p>
  </blockquote>
  
  <p>I did the same thing from pyspark shell and I was able to retrieve data. This is the command I ran: </p>
  
  <pre><code>pyspark --conf "spark.mongodb.input.uri=mongodb_uri" --conf "spark.mongodb.output.uri=mongodburi" --packages org.mongodb.spark:mongo-spark-connector_2.11:2.2.2
  </code></pre>
  
  <p>But here we have the option to specify the package we need to use. But what about standalone apps and scripts. how can I configure mongo-spark-connector there.</p>
  
  <p>Any ideas?</p>