简体   繁体   English

在类路径中的分布式缓存罐,但得到ClassNotFoundException

[英]Distributed Cache Jar in classpath but getting ClassNotFoundException

Using HBaseTestingUtility I would start a minicluster. 使用HBaseTestingUtility我将启动一个小型集群。

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

and provide my jar to place in DistributedCache's classpath 并提供我的jar放在DistributedCache的classpath中

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);

On my MapFn I am using the jar a-1.0.jar. 在我的MapFn上,我正在使用jar-1.0.jar。 I am able to see the jar in the MapFn 我可以在MapFn中看到罐子

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

So I am thinking the jar is in classpath and points to HDFS location but I get classnotfoundexception trying to create an object. 因此,我认为该jar位于classpath中并指向HDFS位置,但是在尝试创建对象时出现classnotfoundexception。 I am not sure whats going on please help. 我不确定发生了什么请帮忙。

I don't know if this the cause of your problem, but the 2 argument overload of addFileToClasspath is deprecated in Hadoop 1.2.1. 我不知道这是否是造成您问题的原因,但是Hadoop 1.2.1中不赞成 addFileToClasspath的2参数重载。 (Indeed in Hadoop 2.7.2, it appears that the DistributedCache class is deprecated in its entirety!) The javadocs don't say why the method has been deprecated, so it is hard to know if this could be the problem. (实际上,在Hadoop 2.7.2中,似乎不推荐使用 DistributedCache类!)javadocs并未说明为什么不推荐使用该方法,因此很难知道这是否是问题所在。

UPDATE 更新

A bit more research suggests that your problem may actually be that the JAR file is not being expanded . 更多的研究表明,您的问题可能实际上是未扩展 JAR文件。 Try using addArchiveToClasspath instead. 尝试改用addArchiveToClasspath

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

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