简体   繁体   中英

java.lang.NoClassDefFoundError for spark-submit

I built *.jar file for my apache spark scala project using maven. When I try to execute the main class, at some line of the code it provides the error Exception in thread "main" java.lang.NoClassDefFoundError for the class org.apache.spark.ml.recommendation.ALS .

I run the spark-submit as follows:

sudo -u hdfs /usr/bin/spark-submit --class 
org.apache.spark.examples.ml.MyTest spark-examples-*.jar --rank 10 --path 
/home/ubuntu/data

It looks like it only cannot find org.apache.spark.ml.recommendation.ALS . I have the following import statements in the class:

package org.apache.spark.examples.ml

import java.util.Date
import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.examples.mllib.AbstractParams
import org.apache.spark.ml.recommendation.ALS
import org.apache.spark.rdd.RDD
import org.apache.spark.sql.{Row, SQLContext}
import scopt.OptionParser

How to solve this issue?

UPDATE 1:

I added maven-assebly plugin to pom.xml and also assembly.xml into the folder resources . Then I successfully made mvn package , but again the same problem.

UPDATE 2:

jar -tvf spark-examples-1.5.3-SNAPSHOT-hadoop2.2.0.jar | grep "ALS"

  2678 Mon May 23 13:11:44 CEST 2016 org/apache/spark/examples/ml/recommendation/MyFunc$ALSParams.class

First find out reason for failure.
1) Is class missing ?
2) or It is initialization problem.

To find out whether class is available run command jar -tvf <.jar> | grep "class name" jar -tvf <.jar> | grep "class name" by this way you can find out whether class file is present or not or its initialization issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM