hadoop mapreduce java program exception: java.lang.NoSuchMethodError [duplicate]

本秂侑毒 提交于 2019-12-12 01:28:42

问题


This is my first experience with Hadoop, and i need help to solve a problem that i am stuck in (as shown in the title).

I found an project that i was looking for: https://github.com/tzulitai/distributed-svm

Before starting to run a mapReduce Job, i executed those three commands on terminal, as the build info said:

$ git clone https://github.com/tzulitai/distributed-svm.git
$ cd distributed-svm
$ mvn clean install

a jar file cascade-svm-mr-0.0.1-SNAPSHOT.jar was generated, and i used it on the the command below to run the mapReduce job:

$ '/usr/local/hadoop/bin/hadoop' jar \
>'/home/hduser/distributed-svm/cascade-svm-mr/target/cascade-svm-mr-0.0.1-SNAPSHOT.jar'\
> ncku.hpds.tzulitai.mapreduce.svm.cascade.CascadeSvm input output

Here is part of the exception is met:

Job[] prepartitionJobs = new Job[prepartitionJobCount];

    prepartitionJobs[0] = new Job(prepartitionConfs[0], "Cascade SVM: Partitioning training data, Phase 1");
    prepartitionJobs[0].setJarByClass(CascadeSvm.class);
    prepartitionJobs[0].setNumReduceTasks(0);   // map-only job
    prepartitionJobs[0].setMapperClass(PreStatCounterMapper.class);
    prepartitionJobs[0].setOutputKeyClass(NullWritable.class);
    prepartitionJobs[0].setOutputValueClass(Text.class);
    FileInputFormat.addInputPath(prepartitionJobs[0], new Path(otherArgs[0]));
    FileOutputFormat.setOutputPath(prepartitionJobs[0], new Path(otherArgs[1]+"/tmp"));
    prepartitionJobs[0].waitForCompletion(true);

(The whole code CascadeSvm.java can be found in the link above).

The error was met in the last line in the code above:

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.hadoop.ipc.RPC.getProxy(Ljava/lang/Class;JLjava/net/InetSocketAddress;Lorg/apache/hadoop/security/UserGroupInformation;Lorg/apache/hadoop/conf/Configuration;Ljavax/net/SocketFactory;ILorg/apache/hadoop/io/retry/RetryPolicy;Z)Lorg/apache/hadoop/ipc/VersionedProtocol;
at org.apache.hadoop.mapred.JobClient.createRPCProxy(JobClient.java:505)
at org.apache.hadoop.mapred.JobClient.init(JobClient.java:496)
at org.apache.hadoop.mapred.JobClient.<init>(JobClient.java:479)
at org.apache.hadoop.mapreduce.Job$1.run(Job.java:563)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1657)
at org.apache.hadoop.mapreduce.Job.connect(Job.java:561)
at org.apache.hadoop.mapreduce.Job.submit(Job.java:549)
at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:580)
at ncku.hpds.tzulitai.mapreduce.svm.cascade.CascadeSvm.main(CascadeSvm.java:485)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)

according to the exception, i noticed that the method waitForCompletion is not recognized or does not exist in the class Job, even when i imported the package Job from mapReduce.

I thought maybe the project was using an old version of Hadoop 2.4.1 and i am currently using Hadoop 2.7.2, so i modified the hadoop version in the pom.xml file, but stil doesn't solve the problem.

This is the pom.xml file:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>ncku.hpds.tzulitai</groupId>
  <artifactId>distributed-svm</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>
  <name>distributed-svm</name>
  <description>Distributed SVM approaches implemented with MapReduce</description>
  <modules>
    <module>cascade-svm-mr</module>
    <module>bagging-svm-mr</module>
  </modules>
  <dependencies>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-common</artifactId>
        <version>2.7.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-mapreduce-client-core</artifactId>
        <version>2.7.2</version>
    </dependency>
    <dependency>
        <groupId>tw.edu.ntu.csie</groupId>
        <artifactId>libsvm</artifactId>
        <version>3.17</version>
    </dependency>
  </dependencies>
  <build>
  <plugins>
    <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
        </configuration>
    </plugin>
   </plugins>
  </build>
</project>

Sorry if my question is too long, but i really need to solve this error, any help will be appreciated, regards.

来源:https://stackoverflow.com/questions/37501168/hadoop-mapreduce-java-program-exception-java-lang-nosuchmethoderror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!