I wrote a spark program with scala,but when I use "spark-submit" to submit my project,I met the java.lang.ClassNotFoundException.
my .sbt file :
name:="Spark Project"
version:="1.0"
scalaVersion:="2.10.5"
libraryDependencies+="org.apache.spark" %% "spark-core" % "1.3.0"
my .scala file's name is SparkProject.scala and in it object's name is SparkProject too.
/* SparkProject.scala */
import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
import org.apache.spark.SparkConf
object SparkProject {
def main(args: Array[String]) {
val logFile = "YOUR_SPARK_HOME/README.md" // Should be some file on your system
val conf = new SparkConf().setAppName("Simple Application")
val sc = new SparkContext(conf)
val logData = sc.textFile(logFile, 2).cache()
val numAs = logData.filter(line => line.contains("a")).count()
val numBs = logData.filter(line => line.contains("b")).count()
println("Lines with a: %s, Lines with b: %s".format(numAs, numBs))
}
}
my command to submit project is :
spark-submit --class "SparkProject" --master local[12] target/scala-2.10/spark-project_2.10-1.0.jar
Anyone knows how to solve this? At last what make me confuse is when I try the example provide here [http://spark.apache.org/docs/latest/quick-start.html],it runs well.But when I build a new project and submit it goes wrong. Any help will be great appreciated.
package namein the class name in your submit command. I guess in your project, your SparkProject.scala file has something likepackage com.exampleas its first line. If it is... then this means that the fully qualified name of your class will becom.example.SparkProjectso you will have to use-- class "com.example.SparkProject".