我们使用的是cdh3u4,Hadoop和HBase。我试图运行一个单元测试,在启动HBaseTestingUtility提供的miniMapReduceCluster后启动MapReduce作业。如何让HBaseTestingUtility在地图缩减作业中查找类?
作业失败,这在地图和减速器任务标准错误日志:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/mapred/Child
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.mapred.Child
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: org.apache.hadoop.mapred.Child. Program will exit.
java.lang.Throwable: Child Error
我一直在试图算出这个数天。我猜它是一个错误的配置,并且由于配置错误的fs/hdfs配置值,群集未找到任何我的jar。 我的测试设置的代码如下所示(借口拼写错误,因为这是从斯卡拉翻译):
HBaseTestingUtility htest = new HBaseTestingUtility();
Configuration c = htest.getConfiguration();
c.set("hadoop.log.dir", "/tmp/hadoop-test-logs"); // required or else can't start the miniMapReduceCluster
htest.startMiniCluster();
htest.startMiniMapReduceCluster();
// create and run a MapReduce job that works in production but not in test
在这种情况下,重要的是,我们使用的播放!框架2.0(使用SBT)和Specs2测试框架和Scala。我认为这不重要(我们没有使用Java + JUnit)。
有没有人见过这个?任何指向哪里看?
由于提前,
马克
马克,你也许想看看Scoobi:http://nicta.github.com/scoobi。在运行Hadoop作业时,有一些测试特征可能会让您的生活更轻松:http://nicta.github.com/scoobi/guide/Testing%20guide.html#Testing+guide – Eric