连接到hadoop时,出现以下错误
线程“主”中的异常java.lang.AbstractMethodError:org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider.getProxy()Lorg / apache / hadoop / io / retry / FailoverProxyProvider $ ProxyInfo;
在org.apache.hadoop.io.retry.RetryInvocationHandler。(RetryInvocationHandler.java:73)
在org.apache.hadoop.io.retry.RetryInvocationHandler。(RetryInvocationHandler.java:64)
在org.apache.hadoop.io.retry.RetryProxy.create(RetryProxy.java:58)
在org.apache.hadoop.hdfs.NameNodeProxies.createProxy(NameNodeProxies.java:147)
在org.apache.hadoop.hdfs.DFSClient。(DFSClient.java:510)
在org.apache.hadoop.hdfs.DFSClient。(DFSClient.java:453)
在org.apache.hadoop.hdfs.DistributedFileSystem.initialize(DistributedFileSystem.java:136)
在org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2653)
在org.apache.hadoop.fs.FileSystem.access $ 200(FileSystem.java:92)
在org.apache.hadoop.fs.FileSystem $ Cache.getInternal(FileSystem.java:2687)
在org.apache.hadoop.fs.FileSystem $ Cache.get(FileSystem.java:2669)
在org.apache.hadoop.fs.FileSystem.get(FileSystem.java:371)
在org.apache.hadoop.fs.FileSystem.get(FileSystem.java:170)
在hrumen.HTest.main(HTest.java:26)
下面是我的代码:
***Path corepath = new Path("/var/tmp/hactive/core-site.xml");
Path sitepath = new Path("/var/tmp/hactive/hdfs-site.xml");
Path yarnpath = new Path("/var/tmp/hactive/yarn-site.xml");
Path mapredpath = new Path("/var/tmp/hactive/mapred-site.xml");
Configuration hconf = new Configuration();
hconf.addResource(corepath);
hconf.addResource(sitepath);
hconf.addResource(yarnpath);
hconf.addResource(mapredpath);
try{
DFSAdmin dfadmin = new DFSAdmin(hconf);
dfadmin.report();
}
catch(Exception e){
//System.out.println("[Exception]: "+e);
e.printStackTrace();
}***
这里是hdfs-site.xml的一部分
...
<property>
<name>dfs.nameservices</name>
<value>mycluster</value>
<final>true</final>
</property>
....
<property>
<name>dfs.client.failover.proxy.provider.mycluster</name>
<value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
</property>
在core-site.xml中
<property>
<name>fs.defaultFS</name>
<value>hdfs://mycluster</value>
</property>
....
最佳答案
尝试运行我的应用程序时(在Hortonworks中),我遇到了同样的问题。卡住之后-花了一段时间,因此在此处添加以供将来引用-以下内容解决了该问题。
要么添加到 pom.xml (注意:版本可能有所不同,请相应设置):
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
<version>2.8.1</version>
</dependency>
或添加:
/path/to/hadoop-hdfs-client-<version_number>.jar
到您的类路径中,以便在运行时包含 hadoop-hdfs-client jar。
关于java - 无法连接Hadoop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47195693/