Support Questions

Find answers, ask questions, and share your expertise
Celebrating as our community reaches 100,000 members! Thank you!

ERROR SparkContext: Error initializing SparkContext

Expert Contributor

I am trying to run my spark Job in Hadoop YARN client mode, and I am using the following command

$/usr/hdp/current/spark-client/bin/spark-submit  --master yarn-client 
--driver-memory 1g 
--executor-memory 1g 
--executor-cores 1 
--files parma1 
--jars param1 param2
--class sparkanalytics.jar param1 param2 param3

spark.driver.extraJavaOptions -Dhdp.verion=
spark.driver.extraLibraryPath /usr/hdp/current/hadoop-client/lib/native:/usr/hdp/current/hadoop-client/lib/native/Linux-amd64-64
spark.eventLog.dir hdfs:///spark-history
spark.eventLog.enabled true
spark.executor.extraLibraryPath /usr/hdp/current/hadoop-client/lib/native:/usr/hdp/current/hadoop-client/lib/native/Linux-amd64-64
spark.history.fs.logDirectory hdfs:///spark-history
spark.history.kerberos.keytab none
spark.history.kerberos.principal none
spark.history.provider org.apache.spark.deploy.history.FsHistoryProvider
spark.history.ui.port 18080 -Dhdp.verion=
spark.yarn.containerLauncherMaxThreads 25
spark.yarn.driver.memoryOverhead 384
spark.yarn.executor.memoryOverhead 384
spark.yarn.historyServer.address clustername:18080
spark.yarn.preserve.staging.files false
spark.yarn.queue default
spark.yarn.scheduler.heartbeat.interval-ms 5000
spark.yarn.submit.file.replication 3

I am getting error below(in attachment).

error-logs.txt - attachment

I could see the below error in yarn application log

$ yarn logs -applicationId application_1510129660245_0004

application-1510129660245-0004-log.txt - attachment

Exception in thread "main" java.lang.ExceptionInInitializerError at javax.crypto.JceSecurityManager.<clinit>( at javax.crypto.Cipher.getConfiguredPermission( at javax.crypto.Cipher.getMaxAllowedKeyLength( at$BulkCipher.isUnlimited(Unknown Source) at$BulkCipher.<init>(Unknown Source) at<clinit>(Unknown Source) at Source) at$100(Unknown Source) at$AbstractTLSContext.<clinit>(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at$Service.getImplClass(Unknown Source) at$Service.newInstance(Unknown Source)         at Source) at Source)

kindly suggest whats going wrong.


Master Mentor

@Sampath Kumar

In your "application-1510129660245-0004-log.txt" file we see the following error:

Caused by: java.lang.SecurityException: Cannot locate policy or framework files!
        at javax.crypto.JceSecurity.setupJurisdictionPolicies(
        at javax.crypto.JceSecurity.access$000(
        at javax.crypto.JceSecurity$
        at Method)
        at javax.crypto.JceSecurity.<clinit>(

Which indicates that your Java/JRE (/usr/java/jre1.8.0_131) does not have the JCE policies installed.

Please refer to the following doc to know the JCE installation steps:

Installing JCE Policy:

# wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" ""

# unzip -o -j -q -d /usr/java/jre1.8.0_131/jre/lib/security/


Above should be done on all the cluster Nodes.


Expert Contributor

@Jay Kumar SenSharma: Thanks for your inputs. I suggested above I have extracted the to /usr/lib/java-1.8.0/jdk1.8.0_144/jre/lib/security folder

[root@dma2 security]# ll
total 184
-rw-r--r--. 1 root root   4054 Nov  8 14:44 blacklist
-rw-r--r--. 1 root root   1273 Nov  8 14:44 blacklisted.certs
-rw-r--r--. 1 root root 114923 Nov  8 14:44 cacerts
-rw-r--r--. 1 root root   2466 Nov  8 14:44 java.policy
-rw-r--r--. 1 root root  35496 Nov  8 14:44
-rw-r--r--. 1 root root     98 Nov  8 14:44 javaws.policy
-rw-rw-r--. 1 root root   3035 Dec 21  2013 local_policy.jar
-rw-r--r--. 1 root root   7323 Dec 21  2013 README.txt
-rw-r--r--. 1 root root      0 Nov  8 14:44 trusted.libraries
-rw-rw-r--. 1 root root   3023 Dec 21  2013 US_export_policy.jar

I have restarted the ambari-server and agent as well. But still I am facing the same issue mentioned above.

Master Mentor

@Sampath Kumar

Only restarting Amabri will not help. You will need to make sure that the JCE policy is installed to all the cluster nodes.

You can check the JVM listed in your application log. Those all should have the JCE installed to it. After installing JCE you will need to restart the services that are running on that JVM. (Like RM,NM ...etc)

Expert Contributor

@Jay Kumar SenSharma: I have a cluster with only one node:-) One node being used as a NN + DN. I have restarted all services. But still same error is still showing up. I am attaching the yarn application log.yarn-application-log.txt. Please let me know if in case I have to restart the machine to affect the jce policy.