Hadoop Eclipse插件构建错误

时间:2013-05-11 12:13:28

标签: java eclipse ant hadoop

我已经安装了Hadoop 1.1.2,并按照步骤构建了http://surajit-paul.blogspot.com/p/eclipse-configuration-for-hadoop-112.html中描述的eclipse-plugin 但是当我想构建插件并运行ant命令时,我得到一个很长的错误列表[javac] 100 errors

ivy-retrieve-common:
[ivy:retrieve] :: retrieving :: org.apache.hadoop#eclipse-plugin [sync]
[ivy:retrieve]  confs: [common]
[ivy:retrieve]  0 artifacts copied, 2 already retrieved (0kB/5ms)
[ivy:cachepath] DEPRECATED: 'ivy.conf.file' is deprecated, use 'ivy.settings.file' instead
[ivy:cachepath] :: loading settings :: file = /Users/majid/Desktop/hadoop-1.1.2/ivy/ivysettings.xml

compile:
 [echo] contrib: eclipse-plugin
[javac] /Users/majid/Desktop/hadoop-1.1.2/src/contrib/eclipse-plugin/build.xml:61: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 45 source files to /Users/majid/Desktop/hadoop-1.1.2/build/contrib/eclipse-plugin/classes
[javac] /Users/majid/Desktop/hadoop-1.1.2/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/dfs/DFSFolder.java:28: package org.apache.hadoop.fs does not exist
[javac] import org.apache.hadoop.fs.FileStatus;
[javac]                            ^
[javac] /Users/majid/Desktop/hadoop-1.1.2/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/dfs/DFSFolder.java:29: package org.apache.hadoop.fs does not exist
[javac] import org.apache.hadoop.fs.Path;
[javac]                            ^
[javac] /Users/majid/Desktop/hadoop-1.1.2/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/dfs/DFSPath.java:25: package org.apache.hadoop.hdfs does not exist
[javac] import org.apache.hadoop.hdfs.DistributedFileSystem;
[javac]                              ^
[javac] /Users/majid/Desktop/hadoop-1.1.2/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/dfs/DFSPath.java:29: package org.apache.hadoop.fs does not exist
[javac] import org.apache.hadoop.fs.FileSystem;
[javac]                            ^
[javac] /Users/majid/Desktop/hadoop-1.1.2/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/dfs/DFSPath.java:30: package org.apache.hadoop.fs does not exist
[javac] import org.apache.hadoop.fs.Path;
[javac]                            ^
[javac] /Users/majid/Desktop/hadoop-1.1.2/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/server/HadoopServer.java:36: package org.apache.hadoop.conf does not exist
[javac] import org.apache.hadoop.conf.Configuration;
[javac]                              ^
[javac] /Users/majid/Desktop/hadoop-1.1.2/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/server/HadoopServer.java:38: package org.apache.hadoop.fs does not exist
[javac] import org.apache.hadoop.fs.FileSystem;
[javac]                            ^
[javac] /Users/majid/Desktop/hadoop-1.1.2/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/server/HadoopServer.java:39: package org.apache.hadoop.io does not exist
[javac] import org.apache.hadoop.io.IOUtils;
[javac]                            ^
[javac] /Users/majid/Desktop/hadoop-1.1.2/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/server/HadoopServer.java:40: package org.apache.hadoop.mapred does not exist
[javac] import org.apache.hadoop.mapred.JobClient;
[javac]                                ^
.
.
.
.
.
[javac] /Users/majid/Desktop/hadoop-1.1.2/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/server/HadoopJob.java:302: package Counters does not exist
[javac]       Counters.Group group = counters.getGroup(groupName);
[javac]               ^
[javac] Note: /Users/majid/Desktop/hadoop-1.1.2/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/server/JarModule.java uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 100 errors

我在这里和那里搜索了很多,但没有任何改变。 我是ant或其他新手的新手。 我真的很感激,如果有人可以帮助我,或者甚至请上传你的hadoop-eclipse-1.1.2.jar插件,如果你已经有了它。

1 个答案:

答案 0 :(得分:2)

您需要包含所有Hadoop依赖项。当你编译你的hadoop程序时,它使用hadoop类并确保编译器可以看到那些hadoop类,你需要告诉它所有Hadoop jar所在的位置。

以下是如何修改build.xml以使用ant设置类路径的示例,但您必须添加完整列表。完整列表是您在eclipse中包含的所有jar,包括您添加的库中的任何jar。

<property name="src" location="my/src/path" />
<property name="bin" location="my/bin/directory" />
<property name="lib" location="/path/to/hadoop/libs/" />
<target name="build" depends="init" description="compiling my hadoop program source">
    <javac srcdir="${src}" destdir="${bin}" debug="on" debuglevel="lines,vars,source" includeantruntime="false" encoding="Cp1252">
        <classpath>
            <pathelement path="${lib}" />
            <pathelement location="${lib}/hadoop-mapreduce-client-core-*.jar" />
            <pathelement location="${lib}/hadoop-mapreduce-client-common-*.jar" />
            ...
            <pathelement location="${lib}/some-other-jar.jar" />
        </classpath>
    </javac>
</target>