0

我是 java 新手并试图运行一个使用 HIPI 的 MR:http://hipi.cs.virginia.edu/ 使用了如下所述的命令: http ://hadoop.apache.org/common/ docs/r0.20.2/mapred_tutorial.html 我正在使用 hadoop 0.20.2

我的命令看起来像: hadoop jar grayscalefromfile_exc.jar grayscalefromfile_exc.StubDriver -libjars hipi-0.0.1.jar imgs imgsOut1

路径如下所示:

 --
   --grayscalefromfile_exc.jar
   --hipi-0.0.1.jar

我得到的错误: org.apache.hadoop.util.ToolRunner.run ( ToolRunner.java:65) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79) at grayscalefromfile_exc.StubDriver.main(StubDriver.java:103) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 在 java.lang.reflect.Method.invoke(Method.java:597) 在 org. apache.hadoop.util.RunJar.main(RunJar.java:186) 引起:java.lang.ClassNotFoundException:hipi.imagebundle。mapreduce.ImageBundleInputFormat 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) ... 还有 9 个

不用说,hipi-0.0.1.jar,里面有路径:hipi/imagebundle/mapreduce/ImageBundleInputFormat.java

肿瘤坏死因子

4

2 回答 2

1

libjars 将给定的 jars 上传到集群,然后使它们在每个映射器/reducer 实例的类路径上可用

如果要向驱动程序客户端类路径添加其他 jar,则需要使用 HADOOP_CLASSPATH 环境变量:

#> export HADOOP_CLASSPATH=hipi-0.0.1.jar
#> hadoop jar grayscalefromfile_exc.jar grayscalefromfile_exc.StubDriver -libjars hipi-0.0.1.jar imgs imgsOut1

当我运行它时我的输出(错误与我没有 hipi 图像包文件的事实有关):

cswhite@Studio-1555:~/workspace/sandbox/so-hipi/target$ export $HADOOP_CLASSPATH=/home/cswhite/Downloads/hipi-0.0.1.jar
cswhite@Studio-1555:~/workspace/sandbox/so-hipi/target$ echo $HADOOP_CLASSPATH
/home/cswhite/Downloads/hipi-0.0.1.jar
cswhite@Studio-1555:~/workspace/sandbox/so-hipi/target$ hadoop jar so-hipi-0.0.1-SNAPSHOT.jar StubDriver -libjars ~/Downloads/hipi-0.0.1.jar images output
num of args: 2:images,output
****hdfs://localhost:9000/user/cswhite/images
12/05/14 14:06:34 INFO input.FileInputFormat: Total input paths to process : 1
12/05/14 14:06:34 INFO mapred.JobClient: Cleaning up the staging area hdfs://localhost:9000/tmp/hadoop-hadoop/mapred/staging/cswhite/.staging/job_201205141351_0003
12/05/14 14:06:34 ERROR security.UserGroupInformation: PriviledgedActionException as:cswhite cause:java.io.IOException: not a hipi image bundle
Exception in thread "main" java.io.IOException: not a hipi image bundle
    at hipi.imagebundle.HipiImageBundle.readBundleHeader(HipiImageBundle.java:322)
    at hipi.imagebundle.HipiImageBundle.openForRead(HipiImageBundle.java:388)
    at hipi.imagebundle.AbstractImageBundle.open(AbstractImageBundle.java:82)
    at hipi.imagebundle.AbstractImageBundle.open(AbstractImageBundle.java:55)
    at hipi.imagebundle.mapreduce.ImageBundleInputFormat.getSplits(ImageBundleInputFormat.java:61)
    at org.apache.hadoop.mapred.JobClient.writeNewSplits(JobClient.java:962)
    at org.apache.hadoop.mapred.JobClient.writeSplits(JobClient.java:979)
    at org.apache.hadoop.mapred.JobClient.access$600(JobClient.java:174)
    at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:897)
    at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:850)
    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:1093)
    at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:850)
    at org.apache.hadoop.mapreduce.Job.submit(Job.java:500)
    at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:530)
    at StubDriver.run(StubDriver.java:53)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79)
    at StubDriver.main(StubDriver.java:57)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:156)
于 2012-05-06T16:14:43.647 回答
0

我能够通过在主类中使用以下 API 来解决类似的问题

DistributedCache.addFileToClassPath(new Path("/path/application.jar"), conf);

jar 必须存在于 hdfs path/path/application.jar中。

于 2012-06-26T17:13:44.673 回答