我用eclipse编程需要连接到Hbase上,我在window->Preferences->Installed JREs 的JREs包里添加了HBase和Hadoop文件里所有的jar包,然后还在build path->libraries里面将上述文件重新添加一遍。将hbase-site.xml文件添加至本项目src的文件夹里面。
初始化程序如下:
public class Zk_test {
Configuration conf;
static Configuration cfg = null;
static {
Configuration HBASE_CONFIG = new Configuration();
HBASE_CONFIG.set("hbase.zookeeper.quorum", "192.168.2.101");
HBASE_CONFIG.set("hbase.zookeeper.property.clientPort", "8080");
// cfg = new HBaseConfiguration(HBASE_CONFIG);
cfg = HBaseConfiguration.create();
}
/** * @param args */
public static void main(String[] args) {
Zk_test test = new Zk_test();
test.test();
}
public boolean test(){
try{
Configuration conf_HBase = new Configuration();
// conf_HBase = HBaseConfiguration.create();
// conf = HBaseConfiguration.create(conf); hbase-site.xml");
// conf.set("hbase-site.xml", null);
conf_HBase .set("hbase.master","192.168.11.128:60000");
conf_HBase .set("hbase.zookeeper.quorum", "192.168.11.129");
conf_HBase .set("hbase.zookeeper.property.clientPort", "21818");
conf_HBase .set("hbase.master.port", "62345");
conf = HBaseConfiguration.create(conf_HBase);
HBaseAdmin admin = new HBaseAdmin(conf);
return true;
}catch (MasterNotRunningException e){
System.out.println("Sorry,Master is not running!");
e.printStackTrace();
return false;
}catch(ZooKeeperConnectionException e){
System.out.println("Sorry,zookeeper cannot connect right now");
e.printStackTrace();
return false;
}
}
}
*************************************************************************************************************
报错如下:
xception in thread "main" java.lang.NullPointerException
at org.apache.hadoop.hbase.zookeeper.ZKConfig.makeZKProps(ZKConfig.java:64)
at org.apache.hadoop.hbase.zookeeper.ZKConfig.getZKQuorumServersString(ZKConfig.java:249)
at org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.[i](ZooKeeperWatcher.java:146)
at org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.[i](ZooKeeperWatcher.java:126)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getZooKeeperWatcher(HConnectionManager.java:1306)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.setupZookeeperTrackers(HConnectionManager.java:578)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.[i](HConnectionManager.java:569)
at org.apache.hadoop.hbase.client.HConnectionManager.getConnection(HConnectionManager.java:186)
at org.apache.hadoop.hbase.client.HBaseAdmin.[i](HBaseAdmin.java:98)
请问有人会吗? 如果有会的可以加我QQ帮我看看吧。我做毕设卡在这里已经好长时间了,老师说再不弄出来就不让我毕业了。qq:125762466,验证码:柴鹰。 如果能帮我解决把毕设的事情搞定,价格面议
|