# Unable to insert data into ES through spark-submit - works with pyspark

**URL:** <https://discuss.elastic.co/t/unable-to-insert-data-into-es-through-spark-submit-works-with-pyspark/159261>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [December 4, 2018, 12:30am UTC](https://discuss.elastic.co/t/unable-to-insert-data-into-es-through-spark-submit-works-with-pyspark/159261 "2018-12-04T00:30:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rohitgcs](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@rohitgcs](https://discuss.elastic.co/u/rohitgcs)\
**Post date:** [December 4, 2018, 12:30am UTC](https://discuss.elastic.co/t/unable-to-insert-data-into-es-through-spark-submit-works-with-pyspark/159261/1 "2018-12-04T00:30:17Z")

</div>

This is the line I use:  
`.write.options(**es_write_conf).mode("append").format("org.elasticsearch.spark.sql").save(esPath)`

When I run it in a shell launching it with `pyspark -jars /usr/lib/spark/jars/elasticsearch-hadoop-5.6.9.jar` it runs perfectly. But when I tried to run it through `spark-submit -jars /usr/lib/spark/jars/elasticsearch-hadoop-5.6.9.jar` I get a ClassNotFoundException.

What would I need to do to figure out why it doesn't work on spark-submit?

---

<div class="post-metadata">

**Author:** ![james.baiera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james.baiera/32/10209_2.png) [@james.baiera](https://discuss.elastic.co/u/james.baiera)\
**Post date:** [December 12, 2018, 8:02pm UTC](https://discuss.elastic.co/t/unable-to-insert-data-into-es-through-spark-submit-works-with-pyspark/159261/2 "2018-12-12T20:02:22Z")

</div>

Can you add the full ClassNotFoundException text here?

---

<div class="post-metadata">

**Author:** ![rohitgcs](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@rohitgcs](https://discuss.elastic.co/u/rohitgcs)\
**Post date:** [December 13, 2018, 5:36am UTC](https://discuss.elastic.co/t/unable-to-insert-data-into-es-through-spark-submit-works-with-pyspark/159261/3 "2018-12-13T05:36:49Z")

</div>

Error output here in the gist:

> <https://gist.github.com/rohitgcs/17940e4804b15aa0855b420539a86805>

---

<div class="post-metadata">

**Author:** ![rohitgcs](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@rohitgcs](https://discuss.elastic.co/u/rohitgcs)\
**Post date:** [December 20, 2018, 6:36am UTC](https://discuss.elastic.co/t/unable-to-insert-data-into-es-through-spark-submit-works-with-pyspark/159261/4 "2018-12-20T06:36:51Z")

</div>

@james.baiera any idea why this would happen?

---

<div class="post-metadata">

**Author:** ![james.baiera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james.baiera/32/10209_2.png) [@james.baiera](https://discuss.elastic.co/u/james.baiera)\
**Post date:** [January 2, 2019, 4:40pm UTC](https://discuss.elastic.co/t/unable-to-insert-data-into-es-through-spark-submit-works-with-pyspark/159261/5 "2019-01-02T16:40:39Z")

</div>

This seems like a pretty strange problem here. I would check to make sure that you are using the correct ES-Hadoop version for your distribution of Spark as well as for your distribution of Scala.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 30, 2019, 4:40pm UTC](https://discuss.elastic.co/t/unable-to-insert-data-into-es-through-spark-submit-works-with-pyspark/159261/6 "2019-01-30T16:40:40Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
