java - 在 Eclipse 中运行 hadoop 作业时出现异常

标签 java eclipse hadoop jar launch

我正在尝试运行 Hadoop wordcount 作业(我使用的是 hadoop 2.6.0)。当我将我的项目导出到可运行的 jar 并从 CLI 运行它时,它就可以工作了。但是,当我在 Eclipse 中使用“作为 Java 应用程序运行”启动它时,我收到以下异常:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at org.apache.hadoop.conf.Configuration.(Configuration.java:173) at WordCount.main(WordCount.java:54) Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory 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 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 2 more

谁能帮我解决这个问题?

最佳答案

我认为您没有正确配置 Eclipse,它不知道在哪里可以找到 Apache Commons 库 jar。来自 this tutorial ,您可能错过了最后的步骤:

To run tests from Eclipse you need to additionally do the following:

  • Under project Properties, select Java Build Path, and the Libraries tab
  • Click "Add External Class Folder" and select the build directory of the current project

您可能还想看看 this other tutorial它显示了如何/在何处添加依赖项 jar 以运行 Hadoop 程序。

关于java - 在 Eclipse 中运行 hadoop 作业时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32011026/

相关文章:

eclipse - eclipse 中是否有 "go to test"的热键

python - 将列表元素转换为数组

java - 重构 - 应合并可折叠的 "if"语句

eclipse - 使用 Tomcat 和 JSP 文件不会编译

java - ExcecutorService什么时候执行失败?

java - JaxB 重命名具有重复名称的类

eclipse - 安装hadoop插件以实现 eclipse 氧气

hadoop - oozie Sqoop 操作无法将数据导入配置单元

java - Netbeans 的项目属性中缺少包装

java - 应用程序在打开时立即崩溃