Overview
When running a Java program that accesses a Hadoop cluster, the following error occurs.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/conf/Configuration
at org.example.Main.main(Main.java:18)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.conf.Configuration
at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 1 more
package org.example;
public class Main {
public static void main(String[] args) throws IOException {
Configuration configuration = new Configuration();
configuration.set("fs.defaultFS", "hdfs://my_hdfs_fqdn:8020");
FileSystem fileSystem = FileSystem.get(configuration);
String directoryName = "tmp/test";
Path path = new Path(directoryName);
fileSystem.mkdirs(path);
}
}
Solution
By commenting out the scope in the dependency, you can resolve the error where the class cannot be found.
<!-- <scope>provided</scope> -->
Quiz
Q1: What is the main topic covered in "How to Fix Hadoop-Client NoClassDefFoundError
(IntelliJ)"?
How to fix Hadoop-Client NoClassDefFoundError
By commenting out the scope in the dependency, you can resolve the error where the class cannot be
found.
현재 단락 (1/27)
When running a Java program that accesses a Hadoop cluster, the following error occurs.