Return-Path: X-Original-To: apmail-hadoop-common-user-archive@www.apache.org Delivered-To: apmail-hadoop-common-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0F5E597AF for ; Thu, 29 Nov 2012 15:31:33 +0000 (UTC) Received: (qmail 56403 invoked by uid 500); 29 Nov 2012 15:31:28 -0000 Delivered-To: apmail-hadoop-common-user-archive@hadoop.apache.org Received: (qmail 56276 invoked by uid 500); 29 Nov 2012 15:31:27 -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 56264 invoked by uid 99); 29 Nov 2012 15:31:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Nov 2012 15:31:27 +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 sandeepjangra@gmail.com designates 209.85.216.176 as permitted sender) Received: from [209.85.216.176] (HELO mail-qc0-f176.google.com) (209.85.216.176) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Nov 2012 15:31:21 +0000 Received: by mail-qc0-f176.google.com with SMTP id n41so12043651qco.35 for ; Thu, 29 Nov 2012 07:31:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=cVKQF3hJ7gpB2jYWIsEUWhWNgbNu7P2G3IcUqw3ZtMc=; b=G0pZk279P+6xTObxK2+xiDM2jzFvWeH0t+mdZUe69RFMmZxWUthLWrnbfxPcxR5KB/ CL2BiLtYZu1lcy3g9JliCxW1YhU7hrm+9FhVx6Dkb6dCSbD9Asdt2nN6mZOZTPRco+Vi PmsWhNmDxWU/RFbRJb/mRk9UF4e6rs07Mwm3dqMKBTLxZw+D6i8HHInABuvQF53nW3a5 qdBfPQOyecio0ViG7cLqABRdeKVtxYy8xHHLzAIXdS911FjR6X4yYdPZQYwGPd4mdrs3 n0ITek2Cj/4HmG9srZC+h8Htz3tmdJJh7vYZqNxiohz55/zAN+Y0OZ4VeDJHNXuK6iCK pnHA== MIME-Version: 1.0 Received: by 10.49.127.199 with SMTP id ni7mr29349324qeb.17.1354203060520; Thu, 29 Nov 2012 07:31:00 -0800 (PST) Received: by 10.49.85.71 with HTTP; Thu, 29 Nov 2012 07:31:00 -0800 (PST) Date: Thu, 29 Nov 2012 10:31:00 -0500 Message-ID: Subject: Trouble with Word Count example From: Sandeep Jangra To: user@hadoop.apache.org Content-Type: multipart/alternative; boundary=047d7b6dcbd66046fc04cfa3f85b X-Virus-Checked: Checked by ClamAV on apache.org --047d7b6dcbd66046fc04cfa3f85b Content-Type: text/plain; charset=ISO-8859-1 Hello everyone, Like most others I am also running into some problems while running my word count example. I tried the various suggestion available on internet, but I guess it;s time to go on email :) Here is the error that I am getting: 12/11/29 10:20:59 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same. 12/11/29 10:20:59 WARN mapred.JobClient: No job jar file set. User classes may not be found. See JobConf(Class) or JobConf#setJar(String). 12/11/29 10:20:59 INFO input.FileInputFormat: Total input paths to process : 1 12/11/29 10:20:59 INFO util.NativeCodeLoader: Loaded the native-hadoop library 12/11/29 10:20:59 WARN snappy.LoadSnappy: Snappy native library is available 12/11/29 10:20:59 INFO snappy.LoadSnappy: Snappy native library loaded 12/11/29 10:21:00 INFO mapred.JobClient: Running job: job_201210310210_0040 12/11/29 10:21:01 INFO mapred.JobClient: map 0% reduce 0% 12/11/29 10:21:07 INFO mapred.JobClient: Task Id : attempt_201210310210_0040_m_000000_0, Status : FAILED java.lang.RuntimeException: *java.lang.ClassNotFoundException: Class WordCount2$Map *not found at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:1439) at org.apache.hadoop.mapreduce.task.JobContextImpl.getMapperClass(JobContextImpl.java:191) at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:605) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:325) at org.apache.hadoop.mapred.Child$4.run(Child.java:270) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:416) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1232) at org.apache.hadoop.mapred.Child.main(Child.java:264) Caused by: java.lang.ClassNotFoundException: Class WordCount2$Map not found at org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:1350) at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:1437) ... 8 more And here is the source code: 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.LongWritable; 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.input.TextInputFormat; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; import java.io.IOException; import java.util.StringTokenizer; public class WordCount2 extends Configured implements Tool { public static class Map extends Mapper { private final static IntWritable one = new IntWritable(1); private Text word = new Text(); @Override protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { String line = value.toString(); StringTokenizer tokenizer = new StringTokenizer(line); while (tokenizer.hasMoreTokens()) { word.set(tokenizer.nextToken()); context.write(word, one); } } } public static class Reduce extends Reducer { @Override protected void reduce(Text key, Iterable values, Context context) throws IOException, InterruptedException { int sum = 0; for(IntWritable value : values) { sum += value.get(); } // while (values.hasNext()) { // sum += values.next().get(); // } context.write(key, new IntWritable(sum)); } } @Override public int run(String[] args) throws Exception { Configuration conf = getConf(); for (java.util.Map.Entry entry: conf) { System.out.printf("%s=%s\n", entry.getKey(), entry.getValue()); } System.out.println("arg[0]= "+args[0] + " args[1]= "+ args[1]); Job job = new Job(conf, WordCount2.class.getSimpleName()); job.setJobName("wordcount2"); job.setJarByClass(WordCount2.class); job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(IntWritable.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(IntWritable.class); job.setMapperClass(Map.class); job.setCombinerClass(Reduce.class); job.setReducerClass(Reduce.class); job.setInputFormatClass(TextInputFormat.class); job.setOutputFormatClass(TextOutputFormat.class); FileInputFormat.setInputPaths(job, new Path(args[0])); FileOutputFormat.setOutputPath(job, new Path(args[1])); System.exit(job.waitForCompletion(true) ? 0 : 1); return 0; } public static void main(String[] args) throws Exception { int exitCode = ToolRunner.run(new WordCount2(), args); System.exit(exitCode); } } --047d7b6dcbd66046fc04cfa3f85b Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hello everyone,

=A0 Like most others I am also running i= nto some problems while running my word count example.
=A0 I trie= d the various suggestion available on internet, but I guess it;s time to go= on email :)
=A0=A0
=A0 Here is the error that I am getting:
= =A0=A012/11/29 10:20:59 WARN mapred.JobClient: Use GenericOptionsParser for= parsing the arguments. Applications should implement Tool for the same.
12/11/29 10:20:59 WARN mapred.JobClient: No job jar file set. =A0User class= es may not be found. See JobConf(Class) or JobConf#setJar(String).
12/11/29 10:20:59 INFO input.FileInputFormat: Total input paths to proces= s : 1
12/11/29 10:20:59 INFO util.NativeCodeLoader: Loaded the native-hadoop= library
12/11/29 10:20:59 WARN snappy.LoadSnappy: Snappy native = library is available
12/11/29 10:20:59 INFO snappy.LoadSnappy: Sn= appy native library loaded
12/11/29 10:21:00 INFO mapred.JobClient: Running job: job_201210310210= _0040
12/11/29 10:21:01 INFO mapred.JobClient: =A0map 0% reduce 0= %
12/11/29 10:21:07 INFO mapred.JobClient: Task Id : attempt_2012= 10310210_0040_m_000000_0, Status : FAILED
java.lang.RuntimeException: java.lang.ClassNotFoundException: Class= WordCount2$Map not found
at org.apache.hadoop.conf.Configuration.getClass(Configuration.ja= va:1439)
at org.apache.hadoop.mapr= educe.task.JobContextImpl.getMapperClass(JobContextImpl.java:191)
at org.apache.hadoop.mapred.M= apTask.runNewMapper(MapTask.java:605)
at org.apache.hadoop.mapr= ed.MapTask.run(MapTask.java:325)
at org.apache.hadoop.mapred.Child$4.run(Child.java:270)
at java.security.AccessCo= ntroller.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:416)
at org.apache.hadoop.secu= rity.UserGroupInformation.doAs(UserGroupInformation.java:1232)
at org.apache.hadoop.mapred.Chil= d.main(Child.java:264)
Caused by: java.lang.ClassNotFoundException: Class WordCount2$Map not = found
at org.apache.= hadoop.conf.Configuration.getClassByName(Configuration.java:1350)
at org.apache.hadoop.conf= .Configuration.getClass(Configuration.java:1437)
... 8 more

And here is the source code:

<= div>
import org.apache.hadoop.conf.Configuration;
i= mport org.apache.hadoop.conf.Configured;
import org.apache.hadoop= .fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.h= adoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoo= p.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apach= e.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.h= adoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hado= op.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
<= div>import org.apache.hadoop.util.Tool;
import org.apache.hadoop.= util.ToolRunner;

import java.io.IOException;
import java.util.StringTokenizer;

public clas= s WordCount2 extends Configured implements Tool {

=
=A0 =A0 public static class Map extends Mapper<LongWritab= le, Text, Text, IntWritable> {
=A0 =A0 =A0 =A0 private final static IntWritable one =3D new IntWritab= le(1);
=A0 =A0 =A0 =A0 private Text word =3D new Text();

=A0 =A0 =A0 =A0 @Override
=A0 =A0 =A0 =A0 protec= ted void map(LongWritable key, Text value, Context context) throws IOExcept= ion, InterruptedException {
=A0 =A0 =A0 =A0 =A0 =A0 String line =3D value.toString();
= =A0 =A0 =A0 =A0 =A0 =A0 StringTokenizer tokenizer =3D new StringTokenizer(l= ine);
=A0 =A0 =A0 =A0 =A0 =A0 while (tokenizer.hasMoreTokens()) {=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 word.set(tokenizer.nextToken());=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 context.write(word, one);
= =A0 =A0 =A0 =A0 =A0 =A0 }
=A0 =A0 =A0 =A0 }

<= div>=A0 =A0 }


=A0 =A0 public static= class Reduce extends Reducer<Text, IntWritable, Text, IntWritable> {=

=A0 =A0 =A0 =A0 @Override
=A0 =A0 =A0 =A0 pro= tected void reduce(Text key, Iterable<IntWritable> values, Context co= ntext) throws IOException, InterruptedException {

= =A0 =A0 =A0 =A0 =A0 =A0 int sum =3D 0;

=A0 =A0 =A0 =A0 =A0 =A0 for(IntWritable value : values)= {
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sum +=3D value.get();
=A0 =A0 =A0 =A0 =A0 =A0 }
// =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0while (values.hasNext()) = {
// =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0sum +=3D values.next().get();
// =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0}
=A0 =A0 =A0 =A0 =A0 =A0 context.write(key, new IntWritable(sum));
=A0 =A0 =A0 =A0 }

=A0 =A0 }

=A0 =A0 @Override
=A0 =A0 public int run(String[] args) = throws Exception {
=A0 =A0 =A0 =A0 Configuration conf =3D getConf();
=A0 =A0 =A0 =A0= for (java.util.Map.Entry<String, String> entry: conf) {
= =A0 =A0 =A0 =A0 =A0 =A0 System.out.printf("%s=3D%s\n", entry.getK= ey(), entry.getValue());
=A0 =A0 =A0 =A0 }

=A0 =A0 =A0 =A0 System.out.= println("arg[0]=3D "+args[0] + " args[1]=3D "+ args[1])= ;

=A0 =A0 =A0 =A0 Job job =3D new Job(conf, WordCo= unt2.class.getSimpleName());
=A0 =A0 =A0 =A0 job.setJobName("wordcount2");
=A0 = =A0 =A0 =A0 job.setJarByClass(WordCount2.class);

= =A0 =A0 =A0 =A0 job.setMapOutputKeyClass(Text.class);
=A0 =A0 =A0= =A0 job.setMapOutputValueClass(IntWritable.class);

=A0 =A0 =A0 =A0 job.setOutputKeyClass(Text.class);
=A0 =A0 =A0 =A0 job.setOutputValueClass(IntWritable.class);

=A0 =A0 =A0 =A0 job.setMapperClass(Map.class);
= =A0 =A0 =A0 =A0 job.setCombinerClass(Reduce.class);
=A0 =A0 =A0 =A0 job.setReducerClass(Reduce.class);

=A0 =A0 =A0 =A0 job.setInputFormatClass(TextInputFormat.class);
=
=A0 =A0 =A0 =A0 job.setOutputFormatClass(TextOutputFormat.class);

=A0 =A0 =A0 =A0 FileInputFormat.setInputPaths(job, new Path(args[0]));
=A0 =A0 =A0 =A0 FileOutputFormat.setOutputPath(job, new Path(args[1])= );

=A0 =A0 =A0 =A0 System.exit(job.waitForCompleti= on(true) ? 0 : 1);

=A0 =A0 =A0 =A0 return 0;
=A0 =A0 }



=A0 =A0 public static void ma= in(String[] args) throws Exception {
=A0 =A0 =A0 =A0 int exitCode= =3D ToolRunner.run(new WordCount2(), args);
=A0 =A0 =A0 =A0 System.exit(exitCode);
=A0 =A0 }
}=


--047d7b6dcbd66046fc04cfa3f85b--