I am developing a plugin which uses spark-core lib. it is ok when I run it as java application but when I run the plugin in Jenkins it show an error which says that
java.lang.ExceptionInInitializerError
at org.apache.spark.package$.<init>(package.scala:91)
at org.apache.spark.package$.<clinit>(package.scala)
at org.apache.spark.SparkContext$$anonfun$3.apply(SparkContext.scala:185)
at org.apache.spark.SparkContext$$anonfun$3.apply(SparkContext.scala:185)
at org.apache.spark.internal.Logging$class.logInfo(Logging.scala:54)
at org.apache.spark.SparkContext.logInfo(SparkContext.scala:74)
at org.apache.spark.SparkContext.<init>(SparkContext.scala:185)
at org.apache.spark.SparkContext$.getOrCreate(SparkContext.scala:2275)
at org.apache.spark.sql.SparkSession$Builder$$anonfun$8.apply(SparkSession.scala:831)
at org.apache.spark.sql.SparkSession$Builder$$anonfun$8.apply(SparkSession.scala:823)
at scala.Option.getOrElse(Option.scala:121)
at org.apache.spark.sql.SparkSession$Builder.getOrCreate(SparkSession.scala:823)
at com.plugin.goettingen_plugin.HelloWorldBuilder.perform(HelloWorldBuilder.java:88)
at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:75)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:785)
at hudson.model.Build$BuildExecution.build(Build.java:205)
at hudson.model.Build$BuildExecution.doRun(Build.java:162)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:537)
at hudson.model.Run.execute(Run.java:1741)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:408)
Caused by: org.apache.spark.SparkException: Error while locating file spark-version-info.properties
at org.apache.spark.package$SparkBuildInfo$.liftedTree1$1(package.scala:75)
at org.apache.spark.package$SparkBuildInfo$.<init>(package.scala:61)
at org.apache.spark.package$SparkBuildInfo$.<clinit>(package.scala)
... 23 more
Caused by: java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Properties.java:434)
at java.util.Properties.load0(Properties.java:353)
at java.util.Properties.load(Properties.java:341)
at org.apache.spark.package$SparkBuildInfo$.liftedTree1$1(package.scala:64)
... 25 more
I am using the following code to start a spark session:
SparkSession sparkSession = SparkSession.builder().appName("DP-App").master("local[2]").getOrCreate();
The spark-core lib searches the file by a class named as package.java by the following code which returns null:
InputStream resourceStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("spark-version-info.properties");
Since the spark-version-info.properties was present inside spark-core lib, I tried to shift the file to Web-INF but still it failed to load the file. Is there any alternative way to load the file and bypass the above code which is inside the library?
My dependencies are:
<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>1.9.4</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-mllib_2.11</artifactId>
<version>2.0.1</version>
</dependency>
</dependencies>
You are missing spark-version-info.properties
file.
So just create one under ./core/target/extra-resources
λ ~/workspace/big_data/spark/ master* ./build/spark-build-info ./core/target/extra-resources 2.1.1
λ ~/workspace/big_data/spark/ master* cat ./core/target/extra-resources/spark-version-info.properties
version=2.1.1
user=chanhle
revision=dec9aa3b37c01454065a4d8899859991f43d4c66
branch=master
date=2017-06-07T15:12:48Z
url=https://github.com/apache/spark
I am experiencing the same problem too when debugging Spark on IntelliJ.
I ran into the same problem by using worksheets in IntelliJ IDE. Solved it by disabling "Run worksheet in the compiler process"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With