当前位置: 首页 > 知识库问答 >
问题:

线程“main”java中出现异常。lang.NoClassDefFoundError:org/apache/hadoop/util/PlatformName

詹杰
2023-03-14

我知道有很多关于这个例外的帖子,但是我不能解决这个问题。我认为必须编辑类路径来解决它。我试图在hadoop架构体系中运行一个名为远程地图的程序。这是我得到的错误。

Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.util.PlatformName
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.apache.hadoop.util.PlatformName.  Program will exit.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/fs/FsShell
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.fs.FsShell
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.apache.hadoop.fs.FsShell.  Program will exit.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/util/PlatformName
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.util.PlatformName
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.apache.hadoop.util.PlatformName.  Program will exit.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/fs/FsShell
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.fs.FsShell
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.apache.hadoop.fs.FsShell.  Program will exit.
Error could not create input directory /distmap_output_input folder on hdfs file system
/usr/java/jdk1.6.0_32/bin/java

Echo$CLASSPATH给出了一个空行

cat~/。bash_简介说

cat ~/.bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH

更新:

$HADOOP_HOME/usr/lib/HADOOP

$HADOOP_CLASSPATH

/usr/lib/hadoop-0.20-mapreduce/hadoop-ant-2.0。0-mr1-cdh4。4.0.jar:/usr/lib/hadoop‌​-0.20-mapreduce/hadoop-ant。jar:/usr/lib/hadoop-0.20-mapreduce/hadoop-examples-2.0‌​.0-mr1-cdh4。4.0.jar:/usr/lib/hadoop-0.20-mapreduce/hadoop-examples。jar:/usr/lib/h‌​adoop-0.20-mapreduce/hadoop-core。jar:/usr/lib/hadoop-0.20-mapreduce/hadoop-core-2‌​.0.0-mr1-cdh4。4.0.jar:/usr/lib/hadoop-0.20-mapreduce/hadoop-test-2.0。0-mr1-cdh4。4.‌​.0.jar:/usr/lib/hadoop-0.20-mapreduce/hadoop-test。jar:/usr/lib/hadoop-0.20-mapreduce/hadoop-tools-2.0。0-mr1-cdh4。4.0.jar:/usr/lib/hado‌​op-0.20-mapreduce/hadoop-tools。jar:/usr/lib/hadoop-0.20-mapreduce/lib/*jar:/usr/lib/hadoop/hadoop-common。jar:/usr/lib/hadoop/hadoop-common-2.0。0-cdh4。4.0.jar

有人能帮我解决这个问题吗?

谢谢

共有3个答案

宗弘扬
2023-03-14

Hadoop Hadoop_类路径问题

这将是有益的。

谢谢

常永长
2023-03-14

如果你是一个maven用户并面对这个问题-

    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-client</artifactId>
        <version>${hadoop.client.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-common</artifactId>
        <version>${hadoop.client.version}</version>
    </dependency>

注意::hadoop客户端:2.5。2本身并没有带来所有必需的hadoop依赖项。这就是为什么我添加了hadoop common,它带来了所有必需的dep。

吕霍英
2023-03-14

hadoop-auth-2.2.0.jar应该有hadoop2.2.0
为您的版本添加hadoop认证罐

 类似资料: