简体   繁体   English

线程“主”中的异常java.lang.ClassNotFoundException:MaxTemperature

[英]Exception in thread “main” java.lang.ClassNotFoundException:MaxTemperature

I am running a single node hadoop, after trying to run a mapreduce application I got this exception: 在尝试运行mapreduce应用程序后,我正在运行一个节点hadoop,但出现了以下异常:

Exception in thread "main" java.lang.ClassNotFoundException: src.main.java.com.hadoop.bi.MapReduce.MaxTemperature at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:270) at org.apache.hadoop.util.RunJar.main(RunJar.java:201)

and what I ran in terminal was: 我在终端运行的是:

[root@dev MapReduce]# hadoop jar target/MapReduce-0.0.1-SNAPSHOT.jar src/main/java/com/hadoop/bi/MapReduce/MaxTemperature sample.txt /out

and here is my MaxTempreture class content: 这是我的MaxTempreture类内容:

    package com.hadoop.bi.MapReduce;
import org.apache.hadoop.conf.Configuration;
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.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class MaxTemperature {

  public static void main(String[] args) throws Exception {
    if (args.length != 2) {
      System.err.println("Usage: MaxTemperature <input path> <output path>");
      System.exit(-1);
    }
    Configuration conf = new Configuration();
    Job job = new Job(conf, "MaxTemperature");  
    job.setJarByClass(MaxTemperature.class);


    FileInputFormat.addInputPath(job, new Path(args[0]));
    FileOutputFormat.setOutputPath(job, new Path(args[1]));

    job.setMapperClass(MaxTemperatureMapper.class);
    job.setReducerClass(MaxTemperatureReducer.class);

    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(IntWritable.class);

    System.exit(job.waitForCompletion(true) ? 0 : 1);
  }
}

I have followed most of similar problems on the internet but I haven't find the solution yet. 我已经在互联网上关注了大多数类似的问题,但是还没有找到解决方案。 Anyone know what the problem is and how it could be solved ? 任何人都知道问题是什么以及如何解决?

Your command line to execute the said class is not correct. 您执行上述类的命令行不正确。 You are giving path with folders included. 您正在提供包含文件夹的路径。 instead you shall give fully qualified class name 相反,您应提供完全合格的班级名称

[root@dev MapReduce]# hadoop jar target/MapReduce-0.0.1-SNAPSHOT.jar src/main/java/com/hadoop/bi/MapReduce/MaxTemperature sample.txt /out [root @ dev MapReduce]#hadoop jar target / MapReduce-0.0.1-SNAPSHOT.jar src / main / java / com / hadoop / bi / MapReduce / MaxTemperature sample.txt / out

should be changed to 应该更改为

[root@dev MapReduce]# hadoop jar target/MapReduce-0.0.1-SNAPSHOT.jar com/hadoop/bi/MapReduce/MaxTemperature sample.txt /out [root @ dev MapReduce]#hadoop jar target / MapReduce-0.0.1-SNAPSHOT.jar com / hadoop / bi / MapReduce / MaxTemperature sample.txt / out

as per your package heirarchy. 根据您的包裹层次结构。

Hope this helps. 希望这可以帮助。

Try removing the throws Exception statement. 尝试删除throws Exception语句。

You don't need to declare a throwing statement in the main function, since it's the entry point and the last method on the calling stack. 您不需要在main函数中声明throwing语句,因为它是调用堆栈上的入口点和最后一个方法。 It does not need to report to anyone. 它不需要向任何人报告。

I don't know too much about JVM but I'm guessing it's trying to look for a specific main signature, and adding that throws Exception , makes the JVM to not recognize the main method. 我对JVM不太了解,但我猜想它正在寻找特定的 签名,并添加throws Exception ,使JVM无法识别方法。

我认为语法应该像

hadoop jar target/MapReduce-0.0.1-SNAPSHOT.jar com.hadoop.bi.MapReduce.MaxTemperature sample.txt /out

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 线程“主”中的异常java.lang.ClassNotFoundException? - Exception in thread “main” java.lang.ClassNotFoundException? 线程“main”java.lang.ClassNotFoundException中的异常: - Exception in thread “main” java.lang.ClassNotFoundException: 线程“主”中的异常java.lang.ClassNotFoundException:TrackPlayer.MainTrack - Exception in thread “main” java.lang.ClassNotFoundException: TrackPlayer.MainTrack 线程“main”中的异常java.lang.ClassNotFoundException:WordCount - Exception in thread “main” java.lang.ClassNotFoundException: WordCount Docker 错误:线程“主”java.lang.ClassNotFoundException 中的异常 - Docker error: Exception in thread "main" java.lang.ClassNotFoundException 线程“main”中的异常 java.lang.ClassNotFoundException,mapreduce - Exception in thread "main" java.lang.ClassNotFoundException, mapreduce Class.forName 中的线程“main”java.lang.ClassNotFoundException 中的异常 - Exception in thread "main" java.lang.ClassNotFoundException in Class.forName 线程“主”中的异常java.lang.NoClassDefFoundError:MyFile原因:java.lang.ClassNotFoundException: - Exception in thread “main” java.lang.NoClassDefFoundError: MyFile Caused by: java.lang.ClassNotFoundException: 线程“ main”中的异常java.lang.ClassNotFoundException:sample.Main-为什么? - Exception in thread “main” java.lang.ClassNotFoundException: sample.Main - why? Hadoop“ Word”程序在线程“ main”中的异常java.lang.ClassNotFoundException - Word Count Program in Hadoop Exception in thread “main” java.lang.ClassNotFoundException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM