Hadoop:奇怪的ClassNotFoundException [英] Hadoop: strange ClassNotFoundException

查看:519
本文介绍了Hadoop:奇怪的ClassNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到一个classnotfound异常。声明未找到的类不存在,但类名称设置为我的地图减少作业的输入文件列表的路径。

  INFO服务器运行:/ usr / lib / hadoop / bin / hadoop  - agent / process / 155-hue / JOBSUBD / hadoop-conf jar tmp.jar / user / hduser / datasets / / user / hduser / tmp / job_20 / mongodb://slave15/db_8.job_20 

线程main中的异常java.lang.ClassNotFoundException:/ user / hduser / datasets /

at java.lang.Class.forName0(Native方法)
at java.lang.Class。 forName(Class.java:247)
at org.apache.hadoop.util.RunJar.main(Runjar.java:190)

我们可以看到, / user / hduser / datasets / 是输入文件的路径。为什么我得到这个错误为 ClassNotFoundException ?为什么看到它是一个类?






我发现了自己的错误。我有一个包结构。我需要指定我的包信息

  / usr / lib / hadoop / bin / hadoop 
--config / var / run / cloudera-scm-agent / process / 155-hue / JOBSUBD / hadoop-conf
jar tmp.jar org.myorg.tmp / user / hduser / datasets /
/ user / hduser / tmp / job_20 / mongodb://slave15/db_8.job_20

在我的工具中,没有选项将包作为Java的参数。所以我需要没有包装。但是,我有以下错误,因为在这个输入文件路径之前的参数丢失。



我的类直接在它的根的tmp.jar。我的意思是没有org.myorg等...



解决方案:

  jar cmf [manifest_file] [jar_name.jar] -C [folder_of_classes] [path_for_jar_file] 

将manifest_file的内容与jar归档中生成的清单文件合并。在manifest_file中包含以下行
Main-Class:[Name_Of_Class]

解决方案

是否存在包层次(如果没有,你做错误)你仍然需要给它包含 main 的类的名称。

例如,文档有一个示例,其中主类是 org.myorg.WordCount 。即使 WordCount 在默认包中,如果jar文件在清单中不包含主类,则应指定:

  bin / hadoop jar /usr/joe/wordcount.jar WordCount / usr / joe / wordcount / input / usr / joe / wordcount / output 

我假设你也可以在清单中指定主类与任何jar;在这些文档中,类参数显示为可选。


I am getting a classnotfound exception. The class which is claimed to be not found does not exist, but the class name is set as the path to the list of input files for my map reduce jobs.

INFO  server Running: /usr/lib/hadoop/bin/hadoop --config /var/run/cloudera-scm-agent/process/155-hue/JOBSUBD/hadoop-conf jar tmp.jar /user/hduser/datasets/ /user/hduser/tmp/job_20/ mongodb://slave15/db_8.job_20

Exception in thread "main" java.lang.ClassNotFoundException: /user/hduser/datasets/

at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.apache.hadoop.util.RunJar.main(Runjar.java:190)

As we can see, the /user/hduser/datasets/ is the path to the input files. Why am I getting this error as ClassNotFoundException? Why does it see it as a class?


I found my own error. I have a package structure. I need to specify my package information

/usr/lib/hadoop/bin/hadoop 
    --config /var/run/cloudera-scm-agent/process/155-hue/JOBSUBD/hadoop-conf 
    jar tmp.jar org.myorg.tmp /user/hduser/datasets/ 
    /user/hduser/tmp/job_20/ mongodb://slave15/db_8.job_20

In my tool, there is no option for giving the package as argument to Java. So I need to have no packaging. But then I am having the following error since the argument before this input file path is missing.

My classes are directly in the tmp.jar in its root. I mean no org.myorg etc...

SOLUTION:

jar cmf [manifest_file] [jar_name.jar] -C [folder_of_classes] [path_for_jar_file]

it will merge the content of the manifest_file with the generated manifest file in the jar archive. Include the following line in the manifest_file Main-Class: [Name_Of_Class]

解决方案

Whether or not there's a package hierarchy (and if there isn't, you've done Something Wrong) you still need to give it the name of the class containing main.

For example, the docs have an example where the main class is org.myorg.WordCount. Even if WordCount was in the default package, it should be specified if the jar file doesn't include a main class in the manifest:

bin/hadoop jar /usr/joe/wordcount.jar WordCount /usr/joe/wordcount/input /usr/joe/wordcount/output

I'd assume you could also specify the main class in the manifest as with any jar; the class argument is shown as optional in those same docs.

这篇关于Hadoop:奇怪的ClassNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆