title: no valid constructor on spark
body: <p>This is my code:</p>
  
  <pre><code>class FNNode(val name: String)
  
  case class Ingredient(override val name: String, category: String) extends FNNode(name)
  
  
  val ingredients: RDD[(VertexId, FNNode)] = 
  sc.textFile(PATH+"ingr_info.tsv").
        filter(! _.startsWith("#")).
        map(line =&gt; line.split('\t')).
        map(x =&gt; (x(0).toInt ,Ingredient(x(1), x(2))))
  </code></pre>
  
  <p>and there are no errors when I define these variables. However, when trying to execute it:</p>
  
  <pre><code>ingredients.take(1)
  </code></pre>
  
  <p>I get </p>
  
  <pre><code>org.apache.spark.SparkException: Job aborted due to stage failure: Exception while getting task result: java.io.InvalidClassException: $iwC$$iwC$Ingredient; no valid constructor
      at org.apache.spark.scheduler.DAGScheduler.org$apache$spark$scheduler$DAGScheduler$$failJobAndIndependentStages(DAGScheduler.scala:1431)
      at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1419)
  </code></pre>
  
  <p>It seems this could be related to Serialization issues as per the answer <a href="https://stackoverflow.com/questions/32210952/scala-invalidclassexception-no-valid-constructor">here</a> . However, I have no idea of how to solve this if it is indeed a Serialization issue.</p>
  
  <p>I'm following along the code in <a href="https://www.packtpub.com/big-data-and-business-intelligence/apache-spark-graph-processing" rel="nofollow noreferrer">this</a> book by they way, so I would assume this should have at least worked at some point?</p>