I know I'm late to the party but I'm posting this answer as a courtesy to whoever gets this error.
First, when a method inside of a class is called from an RDD map function, spark will attempt to serialize the class encapsulating the method being called. This results is an error because the class contains a reference to the sparkContext (which isn't a serializable object).
The following Stack Overflow questions give an overview of the generic issue and a few solutions. One of which is to create a companion object to the class that holds the private methods being called from the map function.
Overview of the issue: Apache Spark map function org.apache.spark.SparkException: Task not serializable
A possible solution: How to qualify methods as static in Scala?