Return-Path: X-Original-To: apmail-hadoop-mapreduce-user-archive@minotaur.apache.org Delivered-To: apmail-hadoop-mapreduce-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D89EF100FD for ; Fri, 13 Dec 2013 02:18:16 +0000 (UTC) Received: (qmail 12799 invoked by uid 500); 13 Dec 2013 02:18:11 -0000 Delivered-To: apmail-hadoop-mapreduce-user-archive@hadoop.apache.org Received: (qmail 12647 invoked by uid 500); 13 Dec 2013 02:18:11 -0000 Mailing-List: contact user-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hadoop.apache.org Delivered-To: mailing list user@hadoop.apache.org Received: (qmail 12640 invoked by uid 99); 13 Dec 2013 02:18:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Dec 2013 02:18:11 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of xiaotao.cs.nju@gmail.com designates 209.85.128.68 as permitted sender) Received: from [209.85.128.68] (HELO mail-qe0-f68.google.com) (209.85.128.68) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Dec 2013 02:18:06 +0000 Received: by mail-qe0-f68.google.com with SMTP id 1so338313qec.7 for ; Thu, 12 Dec 2013 18:17:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=4bKYTh+GSLwNKF7iv3/KFPr8OQLdLMRPOJFsGpJEFUc=; b=larz4d+y4ittJ9Tsr53cd/FT6/LX6CocFyUE+M56L5ZpoNiPhxcYsArpd3468WPi/Y 8EH1m/MBJS9+U7DkCwXOOL18meNdNhr8NKf6dICxbahlKPdesMok28fLZ3+E2fLwKWFs OV2wwP3ndiTDW+lhKSd8n8e8/gzEe50Ju2WXQZPh96/+1rkfC0IoSsuxEfQoXHEoleO1 YeYw48O4H5FKYO411ZkG/k/+AxWOzTV7MSX400c2MoNW1WNEoGsczomxbN0s32VJhMvj GF8H/LKLy4jOvKiTkbsI5/P0j1uq/LyiDs6FgJubkbYgOZpUk1eqZovg7z+u2tRp+vdH Pfdw== MIME-Version: 1.0 X-Received: by 10.224.25.196 with SMTP id a4mr50290qac.31.1386901065635; Thu, 12 Dec 2013 18:17:45 -0800 (PST) Received: by 10.96.198.97 with HTTP; Thu, 12 Dec 2013 18:17:45 -0800 (PST) In-Reply-To: References: Date: Fri, 13 Dec 2013 10:17:45 +0800 Message-ID: Subject: Re: issue about no class find in running MR job From: Tao Xiao To: user@hadoop.apache.org Content-Type: multipart/alternative; boundary=047d7bea433c5b1b4404ed61118b X-Virus-Checked: Checked by ClamAV on apache.org --047d7bea433c5b1b4404ed61118b Content-Type: text/plain; charset=ISO-8859-1 how did you package and compile your jar ? did you specify the main class for the JAR file you generated ? 2013/12/13 ch huang > hi,maillist: > > i rewrite WordCount.java and try to compile and run it but > it say not find main class ,why? > > [root@CHBM224 myMR]# cat WordCount.java > import java.io.IOException; > import java.util.StringTokenizer; > import org.apache.hadoop.conf.Configuration; > import org.apache.hadoop.conf.Configured; > import org.apache.hadoop.fs.Path; > import org.apache.hadoop.io.IntWritable; > import org.apache.hadoop.io.Text; > import org.apache.hadoop.mapreduce.Job; > import org.apache.hadoop.mapreduce.Mapper; > import org.apache.hadoop.mapreduce.Reducer; > import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; > import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; > import org.apache.hadoop.util.GenericOptionsParser; > import org.apache.hadoop.util.ToolRunner; > import org.apache.hadoop.util.Tool; > public class WordCount extends Configured implements Tool { > public static class TokenizerMapper > extends Mapper{ > private final static IntWritable one = new IntWritable(1); > private Text word = new Text(); > public void map(Object key, Text value, Context context > ) throws IOException, InterruptedException { > StringTokenizer itr = new StringTokenizer(value.toString()); > while (itr.hasMoreTokens()) { > word.set(itr.nextToken()); > context.write(word, one); > } > } > } > public static class IntSumReducer > extends Reducer { > private IntWritable result = new IntWritable(); > public void reduce(Text key, Iterable values, > Context context > ) throws IOException, InterruptedException { > int sum = 0; > for (IntWritable val : values) { > sum += val.get(); > } > result.set(sum); > context.write(key, result); > } > } > private static void usage() throws IOException { > System.err.println("teragen "); > } > public int run(String[] args) throws IOException, InterruptedException, > ClassN > otFoundException { > Job job = Job.getInstance(getConf()); > if (args.length != 2) { > usage(); > return 2; > } > job.setJobName("wordcount"); > job.setJarByClass(WordCount.class); > job.setMapperClass(TokenizerMapper.class); > job.setCombinerClass(IntSumReducer.class); > job.setReducerClass(IntSumReducer.class); > job.setOutputKeyClass(Text.class); > job.setOutputValueClass(IntWritable.class); > FileInputFormat.addInputPath(job, new Path(args[0])); > FileOutputFormat.setOutputPath(job, new Path(args[1])); > return job.waitForCompletion(true) ? 0 : 1; > } > public static void main(String[] args) throws Exception { > int res = ToolRunner.run(new Configuration(), new WordCount(), > args); > System.exit(res); > } > } > [root@CHBM224 myMR]# javac -cp > '/usr/lib/hadoop/*:/usr/lib/hadoop-mapreduce/*' -d ../test WordCount.java > [root@CHBM224 myMR]# hadoop ../test/WordCount > Error: Could not find or load main class ...test.WordCount > --047d7bea433c5b1b4404ed61118b Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
how did you package and compile your jar ? did you specify= the main class for the JAR file you generated ?


2013/12/13 ch huang <justl= ooks@gmail.com>
hi,maillist:
=A0
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 i rewrite WordCount.java and try = to compile and run=A0 it but it say not find main class ,why?
=A0
[root@CHBM224 myMR]# cat WordCount.java
import java.io.IOException;=
import java.util.StringTokenizer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hado= op.conf.Configured;
import org.apache.hadoop.fs.Path;
import org.apac= he.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import or= g.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapr= educe.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFor= mat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.GenericOptionsParser;
import org.apache.ha= doop.util.ToolRunner;
import org.apache.hadoop.util.Tool;
public class WordCount extends Configured implements Tool {
=A0 public static class TokenizerMapper
=A0=A0=A0=A0=A0=A0 extends = Mapper<Object, Text, Text, IntWritable>{
=A0=A0=A0 private final static IntWritable one =3D new IntWritable(1);=
=A0=A0=A0 private Text word =3D new Text();
=A0=A0=A0 public void map(Object key, Text value, Context context
= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ) throws IOExcept= ion, InterruptedException {
=A0=A0=A0=A0=A0 StringTokenizer itr =3D new = StringTokenizer(value.toString());
=A0=A0=A0=A0=A0 while (itr.hasMoreTok= ens()) {
=A0=A0=A0=A0=A0=A0=A0 word.set(itr.nextToken());
=A0=A0=A0=A0=A0=A0=A0 c= ontext.write(word, one);
=A0=A0=A0=A0=A0 }
=A0=A0=A0 }
=A0 }
=A0 public static class IntSumReducer
=A0=A0=A0=A0=A0=A0 extends Re= ducer<Text,IntWritable,Text,IntWritable> {
=A0=A0=A0 private IntWr= itable result =3D new IntWritable();
=A0=A0=A0 public void reduce(Text key, Iterable<IntWritable> val= ues,
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 = Context context
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0 ) throws IOException, InterruptedException {
=A0=A0=A0=A0= =A0 int sum =3D 0;
=A0=A0=A0=A0=A0 for (IntWritable val : values) {
=A0=A0=A0=A0=A0=A0=A0 sum +=3D val.get();
=A0=A0=A0=A0=A0 }
=A0=A0=A0= =A0=A0 result.set(sum);
=A0=A0=A0=A0=A0 context.write(key, result);
= =A0=A0=A0 }
=A0 }
=A0 private static void usage() throws IOException {
=A0=A0=A0 Syst= em.err.println("teragen <num rows> <output dir>");=A0 }
=A0 public int run(String[] args) throws IOException, InterruptedExcep= tion, ClassN=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= otFoundException {
=A0=A0=A0=A0=A0=A0=A0 Job job =3D Job.getInstance(ge= tConf());
=A0=A0=A0=A0=A0=A0=A0 if (args.length !=3D 2) {
=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0 usage();
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return = 2;
=A0=A0=A0=A0=A0=A0=A0 }
=A0=A0=A0=A0=A0=A0=A0 job.setJobName("wordcount");
=A0=A0= =A0=A0=A0=A0=A0 job.setJarByClass(WordCount.class);
=A0=A0=A0=A0=A0=A0= =A0 job.setMapperClass(TokenizerMapper.class);
=A0=A0=A0=A0=A0=A0=A0 job= .setCombinerClass(IntSumReducer.class);
=A0=A0=A0=A0=A0=A0=A0 job.setRed= ucerClass(IntSumReducer.class);
=A0=A0=A0=A0=A0=A0=A0 job.setOutputKeyClass(Text.class);
=A0=A0=A0=A0=A0= =A0=A0 job.setOutputValueClass(IntWritable.class);
=A0=A0=A0=A0=A0=A0=A0= FileInputFormat.addInputPath(job, new Path(args[0]));
=A0=A0=A0=A0=A0= =A0=A0 FileOutputFormat.setOutputPath(job, new Path(args[1]));
=A0=A0=A0=A0=A0=A0=A0 return job.waitForCompletion(true) ? 0 : 1;
=A0 }<= /div>
=A0 public static void main(String[] args) throws Exception {
=A0= =A0=A0=A0=A0=A0=A0 int res =3D ToolRunner.run(new Configuration(), new Word= Count(), args);
=A0=A0=A0=A0=A0=A0=A0 System.exit(res);
=A0 }
}
[root@CHBM224 myMR]# javac -cp '/usr/lib/hadoop/*:/usr/lib/hadoop-= mapreduce/*' -d ../test WordCount.java
[root@CHBM224 myMR]#=A0 hadoop ../test/WordCount
Error: Could not f= ind or load main class ...test.WordCount

--047d7bea433c5b1b4404ed61118b--