Hadoop/Eclipse - Exception NoClassDefFoundError: org/apache/hadoop/fs/FileSystem Solution

Today, I encountered a problem when I was analyzing the project case on the learning log website, and I recorded the solution here.

PS: For specific project operations, please see Hadoop Learning - Log Website Analysis Project Case

There are very specific projects in it, and Wei has successfully implemented it in his distributed hadoop environment step by step. I am very grateful to the author of that blog.

Let me tell you how to solve when we encounter the following error

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/fs/FileSystem

1. Take out and modify the core-default.xml file in hadoop-commom-x.jar, and add the following code:

< property >
< name >fs.hdfs.impl</ name >
< value >org.apache.hadoop.hdfs.DistributedFileSystem</ value >
< description >The FileSystem for hdfs: uris.</ description >
</ property >
2. Add in the code

Configuration configuration = new Configuration();
configuration.set("fs.hdfs.impl",org.apache.hadoop.hdfs.DistributedFileSystem.class.getName());
configuration.set("fs.file.impl",org.apache.hadoop.fs.LocalFileSystem.class.getName());


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325895386&siteId=291194637