使用hbasetestinguility,我将启动一个小型集群。
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。我能在Map上看到jar
final Path[] fus = DistributedCache.getFileClassPaths(config);
所以我认为jar在类路径中并指向hdfs位置,但是我在尝试创建对象时遇到了classnotfoundexception。我不知道发生了什么,请帮忙。
1条答案
按热度按时间lvmkulzt1#
我不知道这是否是你的问题的原因,但是2个参数过载
addFileToClasspath
在hadoop 1.2.1中已弃用(实际上,在hadoop2.7.2中DistributedCache
类已全部弃用!)javadocs没有说明为什么这个方法被弃用,所以很难知道这是否是问题所在。更新
更多的研究表明,您的问题实际上可能是jar文件没有被扩展。尝试使用
addArchiveToClasspath
相反。