• <legend id='ifI00'><style id='ifI00'><dir id='ifI00'><q id='ifI00'></q></dir></style></legend>
    1. <small id='ifI00'></small><noframes id='ifI00'>

      <tfoot id='ifI00'></tfoot>

      • <bdo id='ifI00'></bdo><ul id='ifI00'></ul>

        <i id='ifI00'><tr id='ifI00'><dt id='ifI00'><q id='ifI00'><span id='ifI00'><b id='ifI00'><form id='ifI00'><ins id='ifI00'></ins><ul id='ifI00'></ul><sub id='ifI00'></sub></form><legend id='ifI00'></legend><bdo id='ifI00'><pre id='ifI00'><center id='ifI00'></center></pre></bdo></b><th id='ifI00'></th></span></q></dt></tr></i><div id='ifI00'><tfoot id='ifI00'></tfoot><dl id='ifI00'><fieldset id='ifI00'></fieldset></dl></div>

        为什么 hadoop 无法识别我的 Map 类?

        时间:2023-09-27

          <i id='xYUYz'><tr id='xYUYz'><dt id='xYUYz'><q id='xYUYz'><span id='xYUYz'><b id='xYUYz'><form id='xYUYz'><ins id='xYUYz'></ins><ul id='xYUYz'></ul><sub id='xYUYz'></sub></form><legend id='xYUYz'></legend><bdo id='xYUYz'><pre id='xYUYz'><center id='xYUYz'></center></pre></bdo></b><th id='xYUYz'></th></span></q></dt></tr></i><div id='xYUYz'><tfoot id='xYUYz'></tfoot><dl id='xYUYz'><fieldset id='xYUYz'></fieldset></dl></div>

              <bdo id='xYUYz'></bdo><ul id='xYUYz'></ul>

                  <small id='xYUYz'></small><noframes id='xYUYz'>

                  <tfoot id='xYUYz'></tfoot>
                • <legend id='xYUYz'><style id='xYUYz'><dir id='xYUYz'><q id='xYUYz'></q></dir></style></legend>
                    <tbody id='xYUYz'></tbody>

                  本文介绍了为什么 hadoop 无法识别我的 Map 类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试在 hadoop 2.2.0 上运行我的 PDFWordCount map-reduce 程序,但出现此错误:

                  I am trying to run my PDFWordCount map-reduce program on hadoop 2.2.0 but I get this error:

                  13/12/25 23:37:26 INFO mapreduce.Job: Task Id : attempt_1388041362368_0003_m_000009_2, Status : FAILED
                  Error: java.lang.RuntimeException: java.lang.ClassNotFoundException: Class PDFWordCount$MyMap not found
                      at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:1720)
                      at org.apache.hadoop.mapreduce.task.JobContextImpl.getMapperClass(JobContextImpl.java:186)
                      at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:721)
                      at org.apache.hadoop.mapred.MapTask.run(MapTask.java:339)
                      at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:162)
                      at java.security.AccessController.doPrivileged(Native Method)
                      at javax.security.auth.Subject.doAs(Subject.java:415)
                      at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1491)
                      at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:157)
                  Caused by: java.lang.ClassNotFoundException: Class PDFWordCount$MyMap not found
                      at org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:1626)
                      at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:1718)
                      ... 8 more
                  

                  它说我的地图类是未知的.我有一个集群,在 3 个虚拟机上具有一个 namenod 和 2 个数据节点.

                  It says that my map class is not known. I have a cluster with a namenod and 2 datanodes on 3 VMs.

                  我的主要功能是这样的:

                  My main function is this:

                  public static void main(String[] args) throws Exception {
                      Configuration conf = new Configuration();
                      @SuppressWarnings("deprecation")
                      Job job = new Job(conf, "wordcount");
                  
                      job.setOutputKeyClass(Text.class);
                      job.setOutputValueClass(IntWritable.class);
                  
                      job.setMapperClass(MyMap.class);
                      job.setReducerClass(MyReduce.class);
                  
                      job.setInputFormatClass(PDFInputFormat.class);
                      job.setOutputFormatClass(TextOutputFormat.class);
                  
                      FileInputFormat.addInputPath(job, new Path(args[0]));
                      FileOutputFormat.setOutputPath(job, new Path(args[1]));
                  
                      job.setJarByClass(PDFWordCount.class);
                      job.waitForCompletion(true);
                    }
                  

                  如果我使用这个命令运行我的 jar:

                  If I run my jar using this command:

                  yarn jar myjar.jar PDFWordCount /in /out
                  

                  它以 /in 作为输出路径,并在我的主函数中有 job.setJarByClass(PDFWordCount.class); 时给我错误,如上所示.

                  it takes /in as output path and gives me error while I have job.setJarByClass(PDFWordCount.class); in my main function as you see above.

                  我已经运行了一个简单的 WordCount 项目,它的主要功能与这个主要功能完全一样,为了运行它,我使用了 yarn jar wc.jar MyWordCount/in2/out2,它运行完美.

                  I have run simple WordCount project with main function exactly like this main function and to run it, I used yarn jar wc.jar MyWordCount /in2 /out2 and it run flawlessly.

                  我不明白是什么问题!

                  更新:我试图将我的工作从这个项目转移到我成功使用的 wordcount 项目.我构建了一个包,将相关文件从 pdfwordcount 项目复制到这个包并导出了项目(我的 main 没有更改为使用 PDFInputFormat,所以除了将 java 文件移动到新包之外我什么也没做.)它没有不行.我从其他项目中删除了文件,但它没有用.我将 java 文件移回默认包,但它不起作用!

                  UPDATE: I tried to move my work from this project to wordcount project I have used successfully. I built a package, copied related files from pdfwordcount project to this package and exported the project (my main was not changed to used PDFInputFormat, so I did nothing except moving java files to new package.) It didn't work. I deleted files from other project but it didn't work. I moved java file back to default package but it didn't work!

                  怎么了?!

                  推荐答案

                  我找到了解决这个问题的方法,尽管我无法理解问题到底是什么.

                  I found a way to overcome this problem, even though I couldn't understand what was the problem actually.

                  当我想在 eclipse 中将我的 java 项目导出为 jar 文件时,我有两个选择:

                  When I want to export my java project as a jar file in eclipse, I have two options:

                  1. 将所需的库提取到生成的 JAR 中
                  2. 将所需的库打包到生成的 JAR 中

                  我不知道到底有什么区别,或者有什么大不了的.我曾经选择第二个选项,但如果我选择第一个选项,我可以使用以下命令运行我的作业:

                  I don't know exactly what is the difference or is it a big deal or not. I used to choose second option, but if I choose first option, I can run my job using this command:

                  yarn jar pdf.jar /in /out
                  

                  这篇关于为什么 hadoop 无法识别我的 Map 类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Java mapToInt vs Reduce with map 下一篇:HADOOP :: java.lang.ClassNotFoundException: WordCount

                  相关文章

                  最新文章

                    <bdo id='CyYKV'></bdo><ul id='CyYKV'></ul>

                  1. <small id='CyYKV'></small><noframes id='CyYKV'>

                  2. <tfoot id='CyYKV'></tfoot>

                    1. <legend id='CyYKV'><style id='CyYKV'><dir id='CyYKV'><q id='CyYKV'></q></dir></style></legend>
                      <i id='CyYKV'><tr id='CyYKV'><dt id='CyYKV'><q id='CyYKV'><span id='CyYKV'><b id='CyYKV'><form id='CyYKV'><ins id='CyYKV'></ins><ul id='CyYKV'></ul><sub id='CyYKV'></sub></form><legend id='CyYKV'></legend><bdo id='CyYKV'><pre id='CyYKV'><center id='CyYKV'></center></pre></bdo></b><th id='CyYKV'></th></span></q></dt></tr></i><div id='CyYKV'><tfoot id='CyYKV'></tfoot><dl id='CyYKV'><fieldset id='CyYKV'></fieldset></dl></div>