[Spark 1877] ClassNotFoundException when loading RDD with serialized objects

Updated version of #821