標籤:http java 使用 os 檔案 art
使用以下命令安裝Elicpse外掛程式hadoop-maven-plugins:
$ cd ${HADOOP_HOME}/hadoop-maven-plugins
$ mvn install
然後產生Eclipse工程檔案:
$ cd ${HADOOP_HOME}
$ mvn eclipse:eclipse -DskipTests
最後在Eclipse中按照以下流程匯入原始碼:“File” → “Import”→ “Existing Projects into Workspace”。
這裡可以參考:http://www.aboutyun.com/thread-8211-1-1.html
下面是某個部落格寫的錯誤,其中我只遇到了幾個,我在最後貼出我遇到的錯誤
Error#1. hadoop-streaming裡面的build path有問題,顯示/root/workspace/hadoop-2.2.0-src/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/conf(missing)
解決辦法,remove掉引用就好。
Error#2. hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientFailover.java中報sun.net.spi.nameservice.NameService錯誤,這是一個需要import的包,存在於openjdk中,在Oracle Jdk中沒找到,需要下載一個。NameService是一個介面,在網上找一個NameService放到該包中就好。http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7u40-b43/sun/net/spi/nameservice/NameService.java#NameService
Error#3. /hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineEditsViewer/XmlEditsVisitor.java裡面顯示
import com.sun.org.apache.xml.internal.serialize.OutputFormat;
import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
失敗,這是由於Eclipse的強檢查原則,開啟Java -> Compiler -> Errors/Warnings and under "Deprecated and restricted API" change the setting of "Forbidden reference (access rules)" 將error層級調整到warning層級就好。
Error#4. /hadoop-common/src/test/java/org/apache/hadoop/io/serializer/avro/TestAvroSerialization.java顯示沒有AvroRecord類,在網上搜尋到AvroRecord類放入到同級包中就行了。 http://grepcode.com/file/repo1.maven.org/maven2/org.apache.hadoop/hadoop-common/2.2.0/org/apache/hadoop/io/serializer/avro/AvroRecord.java#AvroRecord
Error#5. org.apache.hadoop.ipc.protobuf包是空的,需要在/hadoop-common/target/generated-sources/java中找到profobuf拷貝到/hadoop-common/src/test/java中就好了. 同時包裡面還缺少了以下三個引用,在GrepCode上找一下,把hadoop-common2.2.0的相應檔案下下來匯入。
org.apache.hadoop.ipc.protobuf.TestProtos.EchoRequestProto;
org.apache.hadoop.ipc.protobuf.TestProtos.EchoResponseProto;
org.apache.hadoop.ipc.protobuf.TestRpcServiceProtos.TestProtobufRpcProto;
Error#6. /hadoop-auth/org/apache/hadoop/security/authentication/client/AuthenricatorTestCase.java中顯示server.start()和server.stop()錯誤,還沒找到原因所在,待檢查~~~
-----------------------------------------分界線-------------------------------------------------
我遇到的錯誤提示56個,其實主要就3個問題
同上Error#1. hadoop-streaming裡面的build path有問題,顯示/root/workspace/hadoop-2.2.0-src/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/conf(missing)
解決辦法,remove掉引用就好,具體右鍵右邊出錯項目->properties->左邊Java Build Path->Source->選定錯誤項->右邊Remove
同上Error#4,解決方案同上
同上Error#5,解決方案同上
然後應該就沒錯了
參考:
http://zhidao.baidu.com/link?url=HC-qIB_XxZ4ZdJtD-gPGI0mmWgE7fGpJC222Ri9hA-ju3iflCEr4IVt7ZogVOU7jYR4Fwew8YUp0opwo_9tdLZ4U-VD5DErkQn8OIhzZQfW