找不到hibinputformat类找不到获取Exception classdef

fdbelqdn  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(458)

hduser@akshay-lenovo-g580:~$hadoop jar/home/hduser/hipidemo.jar helloworld sampleimages.hib sampleimages\u平均警告:$hadoop\u home已弃用。
线程“main”java.lang.noclassdeffounderror中出现异常:org/hipi/imagebundle/mapreduce/hibinputformat位于helloworld.run(helloworld)。java:44)在org.apache.hadoop.util.toolrunner.run(toolrunner。java:65)在org.apache.hadoop.util.toolrunner.run(toolrunner。java:79)在helloworld.main(helloworld。java:67)在sun.reflect.nativemethodaccessorimpl.invoke0(本机方法)位于sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl)。java:57)在sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl。java:43)在java.lang.reflect.method.invoke(方法。java:606)在org.apache.hadoop.util.runjar.main(runjar。java:160)原因:java.lang.classnotfoundexception:org.hipi.imagebundle.mapreduce.hibinputformat at at java.net.urlclassloader$1.run(urlclassloader)。java:366)在java.net.urlclassloader$1.run(urlclassloader。java:355)位于java.net.urlclassloader.findclass(urlclassloader)的java.security.accesscontroller.doprivileged(本机方法)。java:354)在java.lang.classloader.loadclass(类加载器。java:425)在java.lang.classloader.loadclass(classloader。java:358) ... 9个以上
我的代码:

import hipi.image.FloatImage;

import java.io.IOException;

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.Tool;
import org.apache.hadoop.util.ToolRunner;
import org.hipi.image.HipiImageHeader;
import org.hipi.imagebundle.mapreduce.HibInputFormat;

public class HelloWorld extends Configured implements Tool {

public static class HelloWorldMapper extends Mapper<HipiImageHeader,     FloatImage, IntWritable, FloatImage> {
public void map(HipiImageHeader key, FloatImage value, Context context) 
  throws IOException, InterruptedException {
}
}
public static class HelloWorldReducer extends Reducer<IntWritable, FloatImage, IntWritable, Text> {
public void reduce(IntWritable key, Iterable<FloatImage> values, Context context) 
  throws IOException, InterruptedException {
}
}

public int run(String[] args) throws Exception {
  // Check input arguments
  if (args.length != 2) {
   System.out.println("Usage: helloWorld <input HIB> <output directory>");
    System.exit(0);
  }

  // Initialize and configure MapReduce job
  //Job job = Job.getInstance();
  Job job = new Job(getConf(), "Employee Salary");
 // Set input format class which parses the input HIB and spawns map tasks
job.setInputFormatClass(HibInputFormat.class);
// Set the driver, mapper, and reducer classes which express the computation
job.setJarByClass(HelloWorld.class);
job.setMapperClass(HelloWorldMapper.class);
job.setReducerClass(HelloWorldReducer.class);
// Set the types for the key/value pairs passed to/from map and reduce layers
job.setMapOutputKeyClass(IntWritable.class);
job.setMapOutputValueClass(FloatImage.class);
job.setOutputKeyClass(IntWritable.class);
job.setOutputValueClass(Text.class);

// Set the input and output paths on the HDFS
FileInputFormat.setInputPaths(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));

// Execute the MapReduce job and block until it complets
boolean success = job.waitForCompletion(true);

// Return success or failure
return success ? 0 : 1;
 }

 public static void main(String[] args) throws Exception {
  ToolRunner.run(new HelloWorld(), args);
   System.exit(0);
}

}
6fe3ivhb

6fe3ivhb1#

将包含类hibinputformat的jar添加到类路径中。
或者在编译时使用行命令:例如: javac -classpath /lib/jarContainingTheClass.jar /examples/HelloWorld.java

相关问题