I'm running a spark job using spark-submit in yarn cluster mode. To submit input and output file paths at run time, I'm trying to load a property file which contains the input and output paths.
Property file:input.properties
spark.myapp.input /input/path spark.myapp.output /output/path
I'm running my application using below command.
`spark-submit --class Property --master yarn-cluster prop.jar --properties-file input.properties`
Scala Code:
import org.apache.spark.SparkConf import org.apache.spark.SparkContext import java.io.FileInputStream import collection.JavaConversions._ import java.util.Properties; object Property { def main(args: Array[String]) { val conf = new SparkConf().setAppName("myApp"); val sparkContext = new SparkContext(conf); val input=sparkContext.getConf.get("spark.myapp.input") println(input) sparkContext.stop; } }
I'm able to access these properties when I run my program in local and yarn-client mode. But in spark-submit mode, I'm getting below exception.
ERROR yarn.ApplicationMaster: User class threw exception: java.util.NoSuchElementException: spark.myapp.input