Hadoop2.4.0 Eclipse外掛製作
跌跌撞撞兩天裝Hadoop2.4.0的環境,今天終於可以嘗試寫點程式了,想了一想,不得其法,但有一點是肯定的,那就是需要用eclipse,查了一上午的資料,怎麼講的都有,最後鎖定了這個帖子,hadoop2x-eclipse-plugin。想用Github下載,但是最後下載失敗,頁面右側有個Download ZIP,用這個下載成功。下邊來說說我的整個製作過程吧:
- 想匯入到eclipse中製作,但是匯入進去之後覺得麻煩就算了,直接在win7 64位、JDK1.6、ANT1.8的環境下以命令列執行
- 依葫蘆畫瓢,設定eclipse的目錄和hadoop的目錄,在沒有修改任何檔案的情況下直接執行
D:\SDK\hadoop2x-eclipse-plugin-master\src\contrib\eclipse-plugin>ant jar -Dversion=2.4.0 -Declipse.home=D:\WorkTools\MyEclipse10\Common -Dhadoop.home=D:\SDK\hadoop-2.4.0
- 在ivy-resolve-common處卡了大概138分鐘,最後build失敗,檢視原因有兩個,一個是找不到4個依賴包,一個是找不到1個核心包
- 依賴包分別是這些,可能是換路徑了吧:
https://oss.sonatype.org/content/groups/public/com/google/google/1/google-1.jar
https://oss.sonatype.org/content/groups/public/net/java/jvnet-parent/1/jvnet-parent-1.jar
https://oss.sonatype.org/content/groups/public/com/sun/jersey/contribs/jersey-contribs/1.9/jersey-contribs-1.9.jar
https://oss.sonatype.org/content/groups/public/org/eclipse/jetty/jetty-parent/14/jetty-parent-14.jar
- 核心包是commons-lang-2.5.jar
- 想了一下,覺得那四個依賴包似乎沒什麼用,便想跳過那個步驟,想直接進行編譯外掛的步驟,便修改了“hadoop2x-eclipse-plugin-master\src\contrib\eclipse-plugin\build.xml”檔案
<target name="compile" depends="init, ivy-retrieve-common" unless="skip.contrib"> 去掉depends
- 核心包去hadoop2.4目錄找,發現hadoop2.4用的commons-lang-2.6.jar,便在build.xml中找到相應位置改為2.6,這個需要說的是作者可能偷懶,在拷貝檔案中使用的是變數,在配置資訊中直接使用了2.5,不統一,變數配置資訊在“hadoop2x-eclipse-plugin-master\ivy\libraries.properties”檔案中,搜尋“commons-lang.version”將對應的版本改為2.6,好了,在命令列下執行ant,成功在“hadoop2x-eclipse-plugin-master\build\contrib\eclipse-plugin”下生成外掛
- 興奮的拿著外掛跟myeclipse10裡試,失敗(外掛壓根不出現),跟eclipse3.7裡試,失敗(外掛能出現,但是無法正常使用,新增不了location)
- 拿著現成的2.2的外掛均可以正常使用
- 後來經過排查原因myeclipse10裡是因為外掛放的位置不對,不能直接放到plugin裡;eclipse3.7裡失敗是因為外掛還缺少包
- 如何排查的呢?看eclipse的啟動日誌,這個日誌在workplace中的.metadata檔案下的.log檔案,在eclipse3.7裡報的錯誤是無法初始化hadoop,很鬱悶,沒太大幫助,於是就上eclilpse的官網下載了最新版的eclipse4.3.2,將ant語句改為
D:\SDK\hadoop2x-eclipse-plugin-master\src\contrib\eclipse-plugin>ant jar -Dversion=2.4.0 -Declipse.home=D:\WorkTools\eclipse4.3.2 -Dhadoop.home=D:\SDK\hadoop-2.4.0
- 對,改為以eclipse4.3.2為eclipse目錄(這個配置主要就是為生成eclipse外掛提供jar包支援),生成外掛後放到eclipse4.3.2的plugins裡,啟動eclipse並觀察日誌,丟擲異常
java.lang.NoClassDefFoundError: org/apache/commons/collections/map/UnmodifiableMap
- yes~ 折騰了又兩個多小時,終於讓我抓住了,找到這個包,在build.xml中新增上,別忘了在配置資訊中也要新增,就是檔案最下邊的attribute,如果想以後方便,版本號也可以通過變數形式在libraries.properties中維護,搞定後,重新執行ant
- 終於行了,在myeclipse10下也可正常使用了(這麼建立資料夾MyEclipse 10\dropins\hadoop\eclipse\plugins,把外掛扔這個資料夾下邊就行了)
------------------------------------------------最終的build.xml檔案,修改的地方有註釋---------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="jar" name="eclipse-plugin">
<import file="../build-contrib.xml"/>
<path id="eclipse-sdk-jars">
<fileset dir="${eclipse.home}/plugins/">
<include name="org.eclipse.ui*.jar"/>
<include name="org.eclipse.jdt*.jar"/>
<include name="org.eclipse.core*.jar"/>
<include name="org.eclipse.equinox*.jar"/>
<include name="org.eclipse.debug*.jar"/>
<include name="org.eclipse.osgi*.jar"/>
<include name="org.eclipse.swt*.jar"/>
<include name="org.eclipse.jface*.jar"/>
<include name="org.eclipse.team.cvs.ssh2*.jar"/>
<include name="com.jcraft.jsch*.jar"/>
</fileset>
</path>
<path id="hadoop-sdk-jars">
<fileset dir="${hadoop.home}/share/hadoop/mapreduce">
<include name="hadoop*.jar"/>
</fileset>
<fileset dir="${hadoop.home}/share/hadoop/hdfs">
<include name="hadoop*.jar"/>
</fileset>
<fileset dir="${hadoop.home}/share/hadoop/common">
<include name="hadoop*.jar"/>
</fileset>
</path>
<path id="classpath">
<pathelement location="${build.classes}"/>
<path refid="eclipse-sdk-jars"/>
<path refid="hadoop-sdk-jars"/>
</path>
<target name="check-contrib" unless="eclipse.home">
<property name="skip.contrib" value="yes"/>
<echo message="eclipse.home unset: skipping eclipse plugin"/>
</target>
<!-- 這裡我最後刪除了depends="init, ivy-retrieve-common" -->
<target name="compile" depends="init, ivy-retrieve-common" unless="skip.contrib">
<echo message="contrib: ${name}"/>
<javac
encoding="${build.encoding}"
srcdir="${src.dir}"
includes="**/*.java"
destdir="${build.classes}"
debug="${javac.debug}"
deprecation="${javac.deprecation}">
<classpath refid="classpath"/>
</javac>
</target>
<target name="jar" depends="compile" unless="skip.contrib">
<mkdir dir="${build.dir}/lib"/>
<copy todir="${build.dir}/lib/" verbose="true">
<fileset dir="${hadoop.home}/share/hadoop/mapreduce">
<include name="hadoop*.jar"/>
</fileset>
</copy>
<copy todir="${build.dir}/lib/" verbose="true">
<fileset dir="${hadoop.home}/share/hadoop/common">
<include name="hadoop*.jar"/>
</fileset>
</copy>
<copy todir="${build.dir}/lib/" verbose="true">
<fileset dir="${hadoop.home}/share/hadoop/hdfs">
<include name="hadoop*.jar"/>
</fileset>
</copy>
<copy todir="${build.dir}/lib/" verbose="true">
<fileset dir="${hadoop.home}/share/hadoop/yarn">
<include name="hadoop*.jar"/>
</fileset>
</copy>
<copy todir="${build.dir}/classes" verbose="true">
<fileset dir="${root}/src/java">
<include name="*.xml"/>
</fileset>
</copy>
<copy file="${hadoop.home}/share/hadoop/common/lib/protobuf-java-${protobuf.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.home}/share/hadoop/common/lib/log4j-${log4j.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.home}/share/hadoop/common/lib/commons-cli-${commons-cli.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.home}/share/hadoop/common/lib/commons-configuration-${commons-configuration.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.home}/share/hadoop/common/lib/commons-lang-${commons-lang.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<!-- 下邊這行是新增的,原來沒有 -->
<copy file="${hadoop.home}/share/hadoop/common/lib/commons-collections-${commons-collections.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.home}/share/hadoop/common/lib/jackson-core-asl-${jackson.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.home}/share/hadoop/common/lib/jackson-mapper-asl-${jackson.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.home}/share/hadoop/common/lib/slf4j-log4j12-${slf4j-log4j12.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.home}/share/hadoop/common/lib/slf4j-api-${slf4j-api.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.home}/share/hadoop/common/lib/guava-${guava.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.home}/share/hadoop/common/lib/hadoop-auth-${hadoop.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.home}/share/hadoop/common/lib/commons-cli-${commons-cli.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.home}/share/hadoop/common/lib/netty-${netty.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<jar
jarfile="${build.dir}/hadoop-${name}-${version}.jar"
manifest="${root}/META-INF/MANIFEST.MF">
<manifest>
<attribute name="Bundle-ClassPath"
value="classes/,
lib/hadoop-mapreduce-client-core-${hadoop.version}.jar,
lib/hadoop-mapreduce-client-common-${hadoop.version}.jar,
lib/hadoop-mapreduce-client-jobclient-${hadoop.version}.jar,
lib/hadoop-auth-${hadoop.version}.jar,
lib/hadoop-common-${hadoop.version}.jar,
lib/hadoop-hdfs-${hadoop.version}.jar,
lib/protobuf-java-${protobuf.version}.jar,
lib/log4j-${log4j.version}.jar,
lib/commons-cli-1.2.jar,
lib/commons-configuration-1.6.jar,
lib/commons-httpclient-3.1.jar,
<!-- 下邊這行原來寫的是commons-lang-2.5 -->
lib/commons-lang-${commons-lang.version}.jar,
<!-- 下邊這行是新增的,原來沒有 -->
lib/commons-collections-${commons-collections.version}.jar,
lib/jackson-core-asl-1.8.8.jar,
lib/jackson-mapper-asl-1.8.8.jar,
lib/slf4j-log4j12-1.7.5.jar,
lib/slf4j-api-1.7.5.jar,
lib/guava-${guava.version}.jar,
lib/netty-${netty.version}.jar"/>
</manifest>
<fileset dir="${build.dir}" includes="classes/ lib/"/>
<fileset dir="${root}" includes="resources/ plugin.xml"/>
</jar>
</target>
</project>
相關文章
- 網頁外掛製作網頁
- 如何製作 Sketch 外掛
- Eclipse外掛Eclipse
- eclipse 外掛Eclipse
- 「12步」製作 Laravel 外掛 (一)Laravel
- jQuery如何製作自定義外掛jQuery
- eclipse vim外掛Eclipse
- flutter使用platform-channels製作外掛FlutterPlatform
- npm製作外掛、釋出及更新NPM
- Stacks網頁佈局製作外掛網頁
- jQuery外掛製作簡單介紹jQuery
- xlam外掛製作實驗手冊
- 外掛製作--------過NP技術漸漸
- Eclipse安裝lombok外掛及外掛使用案例EclipseLombok
- [eclipse]eclipse之tomcat外掛使用EclipseTomcat
- Rainbond的 Gateway API 外掛製作實踐AIGatewayAPI
- 使用parcel替代webpack製作omi-tap外掛Web
- 10個很棒的 jQuery 外掛和製作教程jQuery
- eclipse中的yaml外掛EclipseYAML
- Eclipse外掛開發demoEclipse
- Eclipse外掛之FindbugsEclipse
- eclipse的propedit外掛地址Eclipse
- eclipse marketplace外掛安裝Eclipse
- Eclipse 安裝Groovy外掛Eclipse
- Eclipse外掛安裝(一)Eclipse
- Eclipse外掛的安裝Eclipse
- eclipse 安裝svn外掛Eclipse
- Jquery外掛Nicescroll 製作漂亮的滾動條jQuery
- ModelGoon:逆向UML Eclipse外掛GoEclipse
- Eclipse-安裝SVN外掛Eclipse
- Activiti之eclipse外掛安裝Eclipse
- Eclipse 中 安裝 SVN 外掛Eclipse
- eclipse開發php的外掛EclipsePHP
- Eclipse 工作流外掛地址Eclipse
- eclipse安裝ADT外掛Eclipse
- eclipse3.3外掛更新攻略Eclipse
- Eclipse外掛安裝總結Eclipse
- 整合Tomcat外掛到EclipseTomcatEclipse