gpt4 book ai didi

hadoop - 尝试从Hadoop URL读取数据,但无法读取错误信息

转载 作者:行者123 更新时间:2023-12-02 20:06:22 24 4
gpt4 key购买 nike

ReadFromHadoopURL文件的内容如下:

package com.felix.hadoop.training;

import java.io.InputStream;
import java.net.URL;

import org.apache.hadoop.fs.FsUrlStreamHandlerFactory;
import org.apache.hadoop.io.IOUtils;

// URLCat
public class ReadFromHadoopURL {

static {
URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory());
}

public static void main(String[] args) throws Exception {
InputStream in = null;
try {
in = new URL(args[0]).openStream();
IOUtils.copyBytes(in, System.out, 4096, false);
} finally {
IOUtils.closeStream(in);
}
}
}

然后,我创建了一个jar文件ReadFromHadoopURL.jar。

然后我运行了这个命令
hadoop jar /home/training/Pradosh/ReadFromHadoopURL.jar ReadFromHadoopURL hdfs://localhost:54310/my/empfile

我收到此错误
Exception in thread "main" java.lang.ClassNotFoundException: ReadFromHadoopURL
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:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.hadoop.util.RunJar.main(RunJar.java:149)

您能帮我调试一下吗?

最佳答案

您可能只需要使用包名完全限定您的类名。 ReadFromHadoopURL应该是com.felix.hadoop.training.ReadFromHadoopURL

hadoop jar /home/training/Pradosh/ReadFromHadoopURL.jar com.felix.hadoop.training.ReadFromHadoopURL hdfs://localhost:54310/my/empfile

关于hadoop - 尝试从Hadoop URL读取数据,但无法读取错误信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22686785/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com