我們使用的是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