[Solved] Exception in thread “main“ org.apache.spark.SparkException: When running with master ‘yarn‘ either

Exception in thread “main” org.apache.spark.SparkException: When running with master ‘yarn’ either HADOOP_CONF_DIR or YARN_CONF_DIR must be set in the environment.
spark-env.sh

export HADOOP_CONF_DIR=/opt/bigdata/hadoop-2.9.2/etc/hadoop/
export YARN_CONF_DIR=/opt/bigdata/hadoop-2.9.2/etc/hadoop/

Read More: