简体   繁体   English

类未找到异常hadoop

[英]Class not found exception hadoop

Hi i am running map reduce word count in hadoop.I am getting this error. 嗨我正在运行地图减少hadoop中的字数。我收到此错误。

Exception in thread "main" java.lang.ClassNotFoundException: -files
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at org.apache.hadoop.util.RunJar.main(RunJar.java:205)

But when i export as runnable jar it is working.But when i trying through maven.it is not working.Please help to resolve the issue. 但是当我导出为runnable jar时它正在工作。但是当我尝试通过maven.it不工作时。请帮助解决问题。

When you export you jar as runnable jar the main class of your application is defined in the manifest. 将jar导出为可运行jar时,应用程序的主类在清单中定义。 If you start it from maven you have to define your main class. 如果你从maven启动它,你必须定义你的主类。 The exception you show means that The run method expects a class as parameter whereas you defined "-files". 您显示的异常表示Run方法期望将类作为参数,而您定义了“ -files”。 So just add the full qualified name of your main class of your mapreduce job before "-files" and it should work. 因此,只需在“ -files”之前添加mapreduce作业的主类的全限定名即可,它应该可以工作。

Edit: See documentation for an example. 编辑:有关示例,请参阅文档 The command will look like the following line. 该命令将如下所示。

hadoop jar myjar.jar com.mycompany.task.Main -files ... hadoop jar myjar.jar com.mycompany.task.Main-文件...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM