【发布时间】:2014-01-01 12:59:58
【问题描述】:
我是 Hadoop 的新手。我已经为虚拟机安装了 oracle 虚拟机并安装了 hortonworks 沙箱的图像。我还在 eclipse 中编写了 wordcount 程序并尝试在虚拟机中运行它。但是我得到了一个异常树。我也在发布程序和错误树。
public class WordCount {
public static class Map extends MapReduceBase implements
Mapper<LongWritable, Text, Text, IntWritable> {
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
public void map(LongWritable key, Text value,
OutputCollector<Text, IntWritable> output, Reporter reporter)
throws IOException {
String line = value.toString();
StringTokenizer tokenizer = new StringTokenizer(line);
while (tokenizer.hasMoreTokens()) {
word.set(tokenizer.nextToken());
output.collect(word, one);
}
}
}
public static class Reduce extends MapReduceBase implements
Reducer<Text, IntWritable, Text, IntWritable> {
public void reduce(Text key, Iterator<IntWritable> values,
OutputCollector<Text, IntWritable> output, Reporter reporter)
throws IOException {
int sum = 0;
while (values.hasNext()) {
sum += values.next().get();
}
output.collect(key, new IntWritable(sum));
}
}
public static void main(String[] args) throws IOException {
JobConf conf = new JobConf(WordCount.class);
conf.setJobName("wordcount");
conf.setOutputKeyClass(Text.class);
conf.setOutputValueClass(IntWritable.class);
conf.setMapperClass(Map.class);
conf.setCombinerClass(Reduce.class);
conf.setReducerClass(Reduce.class);
conf.setInputFormat(TextInputFormat.class);
conf.setOutputFormat(TextOutputFormat.class);
FileInputFormat.setInputPaths(conf, new Path(args[0]));
FileOutputFormat.setOutputPath(conf, new Path(args[1]));
JobClient.runJob(conf);
}
}
[hue@sandbox`]$hadoop jar/usr/lib/wordcount.jar wordcount[-m][-r]
线程主 java.lang.NoClassDefFoundError:jar/usr/lib/wordcount/jar 中的异常
引起:java.lang.ClassNotFoundException:jar.usr.lib.wordcount.jar 在 java.net.URLClassLoader$1.run(URLlassLoader.java:202) 在 java.security.AccessController.doPriviledged(本机方法) 在 java.net.URLClassLoader.findClass(URLClassLoader.java:190) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:306) 在 sun.misc.Launcher$AppClassLoader.loadClass(Laucher.java:301) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:247)
找不到主类:jar/usr/lib/wordcount.jar
我在 64 位机器上使用 Hortonworks+Sandbox+1.3+VirtualBox+RC6 这个版本。
【问题讨论】:
-
除非您提供异常堆栈跟踪,否则我认为没有人可以提出解决方案
-
@Ankur 我已经发布了错误的全屏截图
-
@AnkurShanbhag 你看到了吗????
-
我几乎无法从屏幕截图中找出错误。请复制粘贴您的 VM 控制台上显示的错误日志
-
@AnkurShanbhag 发布了由 hadoop 引起的完整堆栈跟踪