运行mapredurce出现Method threw 'java.lang.IllegalStateException' exception. Cannot evaluate org.apache.hadoop.mapreduce.Job.toString()

执行下述代码后在,创建job后会有上述异常,但是可以执行到最后,但是job没有提交上去执行,在历史里也看不到有执行记录求帮助新手o(╥﹏╥)o。
package MapReducer;

import com.sun.org.apache.bcel.internal.generic.RETURN;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.StringTokenizer;

/**

  • @Describe MapReducer第一个读取文档并计数
  • @Author zhanglei
  • @Date 2019/11/18 22:53
    **/
    public class WordCountApp extends Configured implements Tool {

    public int run(String[] strings) throws Exception {
    String input_path="hdfs://192.168.91.130:8020/data/wc.txt";
    String output_path="hdfs://192.168.91.130:8020/data/outputwc";
    Configuration configuration = getConf();
    final FileSystem fileSystem = FileSystem.get(new URI(input_path),configuration);
    if(fileSystem.exists(new Path(output_path))){
    fileSystem.delete(new Path(output_path),true);
    }
    Job job = Job.getInstance(configuration,"WordCountApp");
    job.setJarByClass(WordCountApp.class);
    job.setMapperClass(WordCountMapper.class);
    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(IntWritable.class);
    job.setReducerClass(WordCountReducer.class);
    job.setInputFormatClass(TextInputFormat.class);
    Path inpath = new Path(input_path);
    FileInputFormat.addInputPath(job,inpath);
    job.setOutputFormatClass(TextOutputFormat.class);
    Path outpath = new Path(output_path);
    FileOutputFormat.setOutputPath(job,outpath);
    return job.waitForCompletion(true) ? 0:1;
    }

    //继承
    public static class WordCountMapper extends Mapper{
    private final static IntWritable one= new IntWritable(1);
    private Text word = new Text();
    public void map(Object key,Text value,Context context) throws IOException, InterruptedException {
    Text t = value;
    StringTokenizer itr = new StringTokenizer(value.toString());
    while(itr.hasMoreTokens()){
    word.set(itr.nextToken());
    context.write(word,one);
    }
    }
    }

    public static class WordCountReducer extends Reducer{
    private final static IntWritable res= new IntWritable(1);
    public void reduce(Text key,Iterable values,Context context) throws IOException, InterruptedException {
    int sum = 0;
    for(IntWritable val:values){
    sum+=val.get();
    }
    res.set(sum);
    context.write(key,res);
    }
    }

    public static void main(String[] args) throws Exception {
    int exitCode = ToolRunner.run(new WordCountApp(), args);
    System.exit(exitCode);
    }

}

qq_16050561
三石弟弟 这个异常不会影响程序执行,问题出在我在重写mapper和reducef的map和reducer方法上参数有问题,程序运行时没有进入自定义的方法,大家可以加上注解@Override 来验证方法参数,看看有没有进入自定义的方法里
2 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

3
java filter 字符过滤功能:java.lang.NoClassDefFoundError.
1
SpringBoot添加JDBC和MyBatis依赖后运行报错
0
Mybaits调用存储过程报错There is no setter for property named 'result' in 'class java.lang.Class'
0
Servlet /claim threw load() exception java.lang.RuntimeException: 启动环境报错,如何解决?
1
IDEA连接HBase出现如下问题 请教一下。
4
[Ljava.lang.Object;]: No default constructor found
2
java.net.ConnectException怎么处理?
5
java.lang.NoClassDefFoundError怎么处理?
2
SSM整合运行Tomcat报错org.springframework.beans.factory.BeanCreationException
0
taotao项目写了一个测试报错
2
Servlet遇到java.lang.NullPointerException问题无法解决,恳求帮助
5
The error SQL: select * from ACT_GE_PROPERTY where NAME_ = ? Cause: java.lang.NullPointerException
0
项目在Windows启动下不报错,而在Linux下启动报错
1
spring3.2.8升级4.3.25,messageSource加载异常。
3
Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection
2
springboot2.x引入spring-boot-starter-data-redis依赖,启动报错
3
maven分布式项目,对于大佬来说非常简单,就是这个空指针怎磨也想不通,命名控制台可以打印出值,但是就是报错,dubbo微服务框架
1
springboot2.0.2 启动报错
1
将一个简单的数据库查询部署到Tomcat时java.lang.NoClassDefFoundError: Could not initialize class
3
javaWEb项目查询的是后报错连接池的问题