title: Spark - Scala - saveAsHadoopFile throwing error
body: <p>I would like to troubleshoot the issue but couldn't move further. Can anyone please help</p>
  
  <pre><code>import org.apache.hadoop.mapred.lib.MultipleTextOutputFormat
  
  class KeyBasedOutput[T &gt;: Null, V &lt;: AnyRef] extends MultipleTextOutputFormat[T , V] {
  override def generateFileNameForKeyValue(key: T, value: V, leaf: String) = {
  key.toString
  }
  override def generateActualKey(key: T, value: V) = {
   null
  }
  }
  
  val cp1 =sqlContext.sql("select * from d_prev_fact").map(t =&gt; t.mkString("\t")).map{x =&gt; val parts =      x.split("\t") 
      val partition_key = parts(3)
      val rows = parts.slice(0, parts.length).mkString("\t") 
     ("date=" + partition_key.toString, rows.toString)}
  
  cp1.saveAsHadoopFile(FACT_CP)
  </code></pre>
  
  <p>I have got an error as below and not able to debug</p>
  
  <pre><code>scala&gt; cp1.saveAsHadoopFile(FACT_CP,classOf[String],classOf[String],classOf[KeyBasedOutput[String, String]])
  java.lang.RuntimeException: java.lang.NoSuchMethodException: $iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC$KeyBasedOutput.&lt;init&gt;()
      at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:131)
      at org.apache.hadoop.mapred.JobConf.getOutputFormat(JobConf.java:709)
      at org.apache.spark.rdd.PairRDDFunctions.saveAsHadoopDataset(PairRDDFunctions.scala:742)
      at org.apache.spark.rdd.PairRDDFunctions.saveAsHadoopFile(PairRDDFunctions.scala:674)
  </code></pre>
  
  <p>The idea is to write the values into multiple folder based on the Key</p>