<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Spark Job Definition: Spark_Ambiguous_NonJvmUserApp_FailedContainerLaunch in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-Job-Definition-Spark-Ambiguous-NonJvmUserApp/m-p/3457738#M1092</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="599172" data-lia-user-login="DennesTorres" class="lia-mention lia-mention-user"&gt;DennesTorres&lt;/a&gt;&amp;nbsp;-&amp;nbsp;&lt;SPAN&gt;Thanks for using Fabric Community,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As I understand you are trying to run/schedule notebook code using Spark Job Definition in MS Fabric and facing an error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P data-sourcepos="3:1-3:141"&gt;You might be facing this error &lt;CODE&gt;Spark_Ambiguous_NonJvmUserApp_FailedContainerLaunch&lt;/CODE&gt;&amp;nbsp;because your Spark job definition is missing a Spark session.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P data-sourcepos="5:1-5:203"&gt;When you run the code in a notebook, Apache Spark automatically creates a Spark session. However, when you run the same code in a Spark job definition, you need to explicitly create a Spark session.&lt;BR /&gt;In addition, you need to avoid using the &lt;CODE&gt;display()&lt;/CODE&gt; function in your Spark job definition, as it is also not supported.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P data-sourcepos="9:1-9:99"&gt;To fix the error, you need to add the following code to the beginning of your Spark job definition:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;from pyspark.sql import SparkSession

spark = SparkSession.builder.getOrCreate()&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;Once you have added this code, your Spark job definition should run successfully.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;You can also find your issues for Spark Job Definition here:&lt;BR /&gt;&lt;img /&gt;&lt;BR /&gt;&lt;BR /&gt;Hope this helps, Please do let us know if you have further queries.&lt;/P&gt;</description>
    <pubDate>Tue, 03 Oct 2023 13:07:32 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-10-03T13:07:32Z</dc:date>
    <item>
      <title>Spark Job Definition: Spark_Ambiguous_NonJvmUserApp_FailedContainerLaunch</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-Job-Definition-Spark-Ambiguous-NonJvmUserApp/m-p/3456618#M1090</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a notebook which runs sucessfully on my lakehouse.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After that, I created a spark job definition, downloaded the notebooks in format .py, uploaded to the job definition and tested. Of course, I linked the lakehouse to the job definition, the same lakehouse.&lt;BR /&gt;&lt;BR /&gt;I'm getting the error&amp;nbsp;&lt;SPAN&gt;Spark_Ambiguous_NonJvmUserApp_FailedContainerLaunch&lt;BR /&gt;&lt;BR /&gt;I couldn't find reference to this error anywhere. What does it means? It seems like I missed some step related to authentication, but I couldn't identify what.&lt;BR /&gt;&lt;BR /&gt;Thank you in advance!&lt;BR /&gt;&lt;BR /&gt;Kind Regards,&lt;BR /&gt;&lt;BR /&gt;Dennes&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2023 20:35:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-Job-Definition-Spark-Ambiguous-NonJvmUserApp/m-p/3456618#M1090</guid>
      <dc:creator>DennesTorres</dc:creator>
      <dc:date>2023-10-02T20:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: Spark Job Definition: Spark_Ambiguous_NonJvmUserApp_FailedContainerLaunch</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-Job-Definition-Spark-Ambiguous-NonJvmUserApp/m-p/3457691#M1091</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;The innitial message made me think the execution was not started, but going deep on the logs, I discovered the execution started and failed. The trick is that when using a notebook, "spark" is acessible as the current spark session, but when running a spark job, it's not.&lt;BR /&gt;&lt;BR /&gt;As a result, the spark job code needs more details. In this case, a statement to create the session in a variable called "spark":&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;spark = SparkSession.builder &amp;nbsp; \&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .master(&lt;/SPAN&gt;&lt;SPAN&gt;"local[1]"&lt;/SPAN&gt;&lt;SPAN&gt;) &amp;nbsp; \&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .appName(&lt;/SPAN&gt;&lt;SPAN&gt;"SparkByExamples.com"&lt;/SPAN&gt;&lt;SPAN&gt;) \&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .getOrCreate()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Kind Regards,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Dennes&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 03 Oct 2023 12:41:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-Job-Definition-Spark-Ambiguous-NonJvmUserApp/m-p/3457691#M1091</guid>
      <dc:creator>DennesTorres</dc:creator>
      <dc:date>2023-10-03T12:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: Spark Job Definition: Spark_Ambiguous_NonJvmUserApp_FailedContainerLaunch</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-Job-Definition-Spark-Ambiguous-NonJvmUserApp/m-p/3457738#M1092</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="599172" data-lia-user-login="DennesTorres" class="lia-mention lia-mention-user"&gt;DennesTorres&lt;/a&gt;&amp;nbsp;-&amp;nbsp;&lt;SPAN&gt;Thanks for using Fabric Community,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As I understand you are trying to run/schedule notebook code using Spark Job Definition in MS Fabric and facing an error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P data-sourcepos="3:1-3:141"&gt;You might be facing this error &lt;CODE&gt;Spark_Ambiguous_NonJvmUserApp_FailedContainerLaunch&lt;/CODE&gt;&amp;nbsp;because your Spark job definition is missing a Spark session.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P data-sourcepos="5:1-5:203"&gt;When you run the code in a notebook, Apache Spark automatically creates a Spark session. However, when you run the same code in a Spark job definition, you need to explicitly create a Spark session.&lt;BR /&gt;In addition, you need to avoid using the &lt;CODE&gt;display()&lt;/CODE&gt; function in your Spark job definition, as it is also not supported.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P data-sourcepos="9:1-9:99"&gt;To fix the error, you need to add the following code to the beginning of your Spark job definition:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;from pyspark.sql import SparkSession

spark = SparkSession.builder.getOrCreate()&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;Once you have added this code, your Spark job definition should run successfully.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;You can also find your issues for Spark Job Definition here:&lt;BR /&gt;&lt;img /&gt;&lt;BR /&gt;&lt;BR /&gt;Hope this helps, Please do let us know if you have further queries.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2023 13:07:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Spark-Job-Definition-Spark-Ambiguous-NonJvmUserApp/m-p/3457738#M1092</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-10-03T13:07:32Z</dc:date>
    </item>
  </channel>
</rss>

