2016-02-13 34 views
0

使用HBaseTestingUtility我会启动一个minicluster。类路径中的分布式缓存Jar,但获取ClassNotFoundException

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

,并提供我的罐子在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); 

在我MapFn我使用的罐子-1.0.jar的地方。我能看到罐子在MapFn

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

所以我想罐子在classpath中并指向HDFS的位置,但我得到的ClassNotFoundException试图创建一个对象。我不确定发生了什么事,请帮忙。

回答

0

我不知道这是你的问题的原因,但在Hadoop 1.2.1中,addFileToClasspath的2参数过载是deprecated。 (事实上​​,在Hadoop 2.7.2中,看起来DistributedCache类是整体的deprecated!)javadocs不会说为什么该方法已被弃用,因此很难知道这是否可能是问题所在。

UPDATE

了些研究表明,你的问题可能实际上是JAR文件是not being expanded。改为使用addArchiveToClasspath