title: ClassNotFoundException while building jar in SBT
body: <p><strong>Hi all,
  I'm using SBT to build my project, and here is the structure of my project.</strong></p>
  
  <pre><code>HiveGenerator
  ├── build.sbt
  ├---lib
  ├── project
  │   ├── 
  │   ├── assembly.sbt
  │   └── plugins.sbt
  ├── 
  ├── 
  └── src
      └── main
          └── scala
              └── Main.scala  
  </code></pre>
  
  <p>But i'm facing this error <strong>"java.lang.ClassNotFoundException: package.classname"</strong>, no matter how many times i build it.
  I have used,
  sbt clean package
  sbt clean assembly,but with no luck.My class is always missing from the jar.</p>
  
  <p>Here is my build.sbt </p>
  
  <pre><code>lazy val root = (project in file(".")).
   settings(
   name := "kafkaToMaprfs",
  version := "1.0",
  scalaVersion := "2.10.5",
  mainClass in Compile := Some("classname")
   )
   libraryDependencies ++= Seq(
     "org.apache.spark" % "spark-hive_2.10" % "1.6.1",
    "org.apache.spark" % "spark-core_2.10" % "1.6.1",
    "org.apache.spark" % "spark-sql_2.10" % "1.6.1",
    "com.databricks" % "spark-avro_2.10" % "2.0.1",
    "org.apache.avro" % "avro" % "1.8.1",
    "org.apache.avro" % "avro-mapred" % "1.8.1",
    "org.apache.avro" % "avro-tools" % "1.8.1",
    "org.apache.spark" % "spark-streaming_2.10" % "1.6.1",
    "org.apache.spark" % "spark-streaming-kafka_2.10" % "1.6.1",
    "org.codehaus.jackson" % "jackson-mapper-asl" % "1.9.13",
    "org.openrdf.sesame" % "sesame-rio-api" % "2.7.2",
    "log4j" % "log4j" % "1.2.17",
    "com.twitter" % "bijection-avro_2.10" % "0.7.0"
  
   )
  
  
  mergeStrategy in assembly &lt;&lt;= (mergeStrategy in assembly) { (old) =&gt;
     {
      case PathList("META-INF", xs @ _*) =&gt; MergeStrategy.discard
      case x =&gt; MergeStrategy.first
     }
  }
  </code></pre>
  
  <p><strong>Here is my assembly.sbt</strong> </p>
  
  <pre><code>addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.3")
  </code></pre>
  
  <p><strong>plugins.sbt</strong></p>
  
  <pre><code>addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "0.7.0")
  resolvers += Resolver.url("bintray-sbt-plugins", url("http://dl.bintray.com/sbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
  resolvers += "OSS Sonatype" at "https://repo1.maven.org/maven2/"
  </code></pre>
  
  <p>However, im not able to build a fat jar or you can say jar-with-dependencies.jar like in maven.</p>
  
  <p><strong>In maven we have</strong></p>
  
  <pre><code>&lt;descriptorRefs&gt;
  &lt;descriptorRef&gt;jar-with-dependencies&lt;/descriptorRef&gt;
  &lt;/descriptorRefs&gt;
  </code></pre>
  
  <p>Which helped me to accomplish this.</p>
  
  <p>My question is,
  *1. why am i not building a jar with all the classes in it?</p>
  
  <p>2.Which commands should i use to create a jar with dependencies in sbt?</p>
  
  <p>3.To we have anything equivalent to <strong>"descriptorRefs"</strong> in sbt to do the magic?*</p>
  
  <p>Last question , which i didnt find answer to,
  can't we achieve a proper output with sbt should we always use spark-submit to make it happen(not considering local or cluster modes)?</p>
  
  <p>Thanks in advance.</p>