我正在尝试使用hadoop-mapreduce lib的ChainMapper / ChainReducer。
对于我使用的编译,
javac -Xlint -cp /opt/cloudera/parcels/CDH-4.3.0-1.cdh4.3.0.p0.22/lib/hadoop-
mapreduce/*:`hadoop classpath` -d classes *.java
我必须单独包含/opt/cloudera/parcels/CDH-4.3.0-1.cdh4.3.0.p0.22/lib/hadoop-mapreduce/*
,因为编译器会抱怨。 (它不包含在hadoop classpath
)
当我运行jar时它编译得很好,
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/mapreduce/lib/chain/ChainMapper
at job_name.main(job_name.java:72)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.hadoop.util.RunJar.main(RunJar.java:208)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.mapreduce.lib.chain.ChainMapper
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 6 more
我的驱动程序类如下,
Configuration conf = new Configuration(false);
FileSystem fs = FileSystem.get(conf);
Job job = new Job(conf,"job_name");
job.setJarByClass(SetUpJob.class);
FileInputFormat.setInputPaths(job, new Path(args[1]));
FileOutputFormat.setOutputPath(job, new Path(args[2]));
ChainMapper.addMapper(job,Mapper1.class,LongWritable.class,Text.class,Text.class,IntWritable.class,conf);
ChainReducer.setReducer(job,myReducer.class,LongWritable.class,Text.class,BytesWritable.class,IntWritable.class,conf);
ChainReducer.addMapper(job,Mapper2.class,LongWritable.class,Text.class,Text.class,IntWritable.class,conf);
ChainReducer.setReducer(job,myReducer.class,LongWritable.class,Text.class,BytesWritable.class,IntWritable.class,conf);
ChainReducer.addMapper(job,Mapper3.class,LongWritable.class,Text.class,Text.class,IntWritable.class,conf);
ChainReducer.setReducer(job,myReducer.class,LongWritable.class,Text.class,BytesWritable.class,IntWritable.class,conf);
job.setOutputFormatClass(TextOutputFormat.class);
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(IntWritable.class);
job.setOutputKeyClass(BytesWritable.class);
job.setOutputValueClass(Text.class);
System.exit(job.waitForCompletion(true) ? 0 : 1);
我将jar作为hadoop jar jar_name.jar job_name <parameters>
我的运行时环境无法找到该类吗?我该如何设置呢?