【问题标题】:mapreduce code working on eclipse but not on clustermapreduce 代码在 eclipse 上工作但不在集群上
【发布时间】:2014-04-04 08:18:06
【问题描述】:

我正在编写使用 openNLP 的代码。我的代码在 eclipse 上完美运行,但是当我在集群上运行它的 jar 时,出现以下错误:

Exception in thread "main" java.lang.NoClassDefFoundError: opennlp/tools/util/ObjectStream
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at org.apache.hadoop.util.RunJar.main(RunJar.java:153)
Caused by: java.lang.ClassNotFoundException: opennlp.tools.util.ObjectStream
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
... 3 more

【问题讨论】:

    标签: eclipse hadoop opennlp


    【解决方案1】:

    您需要在任务的类路径中提供 OpenNLP jar。有几种选择:

    • -libjars 和 HADOOP_CLASSPATH,请参阅 Using the libjars option with Hadoop
    • 'fat jar':构建一个包含所有必要 jar 的 jar,提交 fat jar 代替
    • 在所有节点上安装第 3 方 jars(即,使集群“感知第 3 方”)
    • 使用 HDFS distributed cache 并在您的代码中下载必要的 jars

    更多讨论请见How-to: Include Third-Party Libraries in Your MapReduce Job

    【讨论】:

    猜你喜欢
    • 2019-10-14
    • 2023-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-01
    • 2020-10-22
    • 1970-01-01
    相关资源
    最近更新 更多