[英]Have hadoop/*-common.jar included still got “java.lang.ClassNotFoundException:org.apache.hadoop.conf.Configuration”
When practicing to realize a "hadoop RPC" sample, I keep getting this error. 在练习实现“ hadoop RPC”示例时,我一直收到此错误。 According to previous similar questions and answers, I've checked the jar file in my classpath and got hadoop common.jar It shows that the jar file in the classpath contains hadoop.conf.Configuration.class.
根据先前类似的问题和答案,我检查了我的类路径中的jar文件,并获取了hadoop common.jar。它显示类路径中的jar文件包含hadoop.conf.Configuration.class。 And here's the code to build RPCServer:
这是构建RPCServer的代码:
*package rpc;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ipc.RPC;
import org.apache.hadoop.ipc.Server;
public class RPCServer implements MyBizable {
public String doSomething(String str) {
return str;
}
public static void main(String[] args) throws Exception {
Server server = new RPC.Builder(new Configuration())
.setProtocol(MyBizable.class)
.setInstance(new RPCServer())
.setBindAddress("***.***.***.***")
.setPort(****)
.build();
server.start();
}
}*
And still this error shows up, anyone knows how to solve it? 仍然显示此错误,有人知道如何解决吗? Any help will be greatly appreciated!
任何帮助将不胜感激! THX in advance!
提前THX!
Are you using Maven ? 您在使用Maven吗? if yes then add below dependencies.
如果是,则在下面添加依赖项。
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>${hadoop.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>${hadoop.version}</version>
<scope>provided</scope>
</dependency>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.