From ec1c11b6f599d950abb5c0496c2c85c5951f9fa7 Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Mon, 26 Oct 2015 18:00:18 +0100 Subject: [PATCH] Set the context class loader in the Mesos executor backend. This fixes the `ClassNotFoundException` for Spark classes in the serializer. --- .../org/apache/spark/executor/MesosExecutorBackend.scala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/main/scala/org/apache/spark/executor/MesosExecutorBackend.scala b/core/src/main/scala/org/apache/spark/executor/MesosExecutorBackend.scala index 0474fd2ccc12..c9f18ebc7f0e 100644 --- a/core/src/main/scala/org/apache/spark/executor/MesosExecutorBackend.scala +++ b/core/src/main/scala/org/apache/spark/executor/MesosExecutorBackend.scala @@ -63,6 +63,11 @@ private[spark] class MesosExecutorBackend logInfo(s"Registered with Mesos as executor ID $executorId with $cpusPerTask cpus") this.driver = driver + // Set a context class loader to be picked up by the serializer. Without this call + // the serializer would default to the null class loader, and fail to find Spark classes + // See SPARK-10986. + Thread.currentThread().setContextClassLoader(this.getClass.getClassLoader) + val properties = Utils.deserialize[Array[(String, String)]](executorInfo.getData.toByteArray) ++ Seq[(String, String)](("spark.app.id", frameworkInfo.getId.getValue)) val conf = new SparkConf(loadDefaults = true).setAll(properties)