【问题标题】:Distributed Cache Jar in classpath but getting ClassNotFoundException类路径中的分布式缓存 Jar 但获取 ClassNotFoundException
【发布时间】:2016-05-24 07:12:04
【问题描述】:

使用 HBaseTestingUtility 我将启动一个小型集群。

testUtil = new HBaseTestingUtility(configuration);
testUtil.startMiniCluster();

并提供我的 jar 放在 DistributedCache 的类路径中

final String aJarResourcePath = Thread.currentThread().getContextClassLoader()
            .getResource("abc/a-1.0.jar").getPath();
    final FileSystem fs = FileSystem.get(configuration);
    final Path pathToArtifacts = new Path("/Runtime/a-artifacts");
        fs.mkdirs(pathToArtifacts);
    fs.copyFromLocalFile(new Path(aJarResourcePath), pathToArtifacts));

DistributedCache.addFileToClassPath(disqualified, configuration);

在我的 MapFn 上,我使用的是 jar a-1.0.jar。我可以在 MapFn 中看到 jar

final Path[] fus = DistributedCache.getFileClassPaths(config);

所以我认为 jar 在类路径中并指向 HDFS 位置,但我得到 classnotfoundexception 试图创建一个对象。我不知道发生了什么请帮忙。

【问题讨论】:

    标签: java hadoop jar classpath distributed-cache


    【解决方案1】:

    我不知道这是否是您的问题的原因,但 addFileToClasspath 的 2 参数重载在 Hadoop 1.2.1 中是 deprecated。 (事实上​​,在 Hadoop 2.7.2 中,DistributedCache 类似乎完全是 deprecated!)javadocs 没有说明 为什么 该方法已被弃用,因此很难知道这是否是问题所在。

    更新

    更多研究表明,您的问题实际上可能是 JAR 文件是 not being expanded。尝试改用addArchiveToClasspath

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-07
      • 2015-12-23
      • 1970-01-01
      • 2016-05-24
      • 1970-01-01
      • 2016-09-04
      相关资源
      最近更新 更多