2015-04-24 203 views
2

我正在使用Java API for HBase編寫簡單的「hello world」應用程序。這裏是我的代碼:HBase Java客戶端api未連接

public static void main(String[] args) throws IOException { 
     Configuration conf = HBaseConfiguration.create(); 
     conf.set("hbase.zookeeper.quorum", "localhost"); 
     conf.set("hbase.zookeeper.property.clientPort", "2181"); 
     HTable table = new HTable(conf, "myTable"); 
     Scan s = new Scan(); 
     s.addColumn(Bytes.toBytes("a"), Bytes.toBytes("b")); 
     ResultScanner scanner = table.getScanner(s); 
     for (Result rr = scanner.next(); rr != null; rr = scanner.next()) { 
      System.out.println("Found row: " + rr); 
     } 
     table.close(); 
    } 

,並導致我得到:

15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:zookeeper.version=3.4.5-1392090, built on 09/30/2012 17:52 GMT 
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:host.name=localhost 
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:java.version=1.8.0_45 
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:java.vendor=Oracle Corporation 
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:java.home=/usr/lib/jvm/java-8-oracle/jre 
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:java.class.path=/home/bartek/workspace/HBaseTester/target/classes:/home/bartek/.m2/repository/org/apache/hadoop/hadoop-core/1.0.4/hadoop-core-1.0.4.jar:/home/bartek/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar:/home/bartek/.m2/repository/xmlenc/xmlenc/0.52/xmlenc-0.52.jar:/home/bartek/.m2/repository/commons-httpclient/commons-httpclient/3.0.1/commons-httpclient-3.0.1.jar:/home/bartek/.m2/repository/commons-codec/commons-codec/1.4/commons-codec-1.4.jar:/home/bartek/.m2/repository/org/apache/commons/commons-math/2.1/commons-math-2.1.jar:/home/bartek/.m2/repository/commons-configuration/commons-configuration/1.6/commons-configuration-1.6.jar:/home/bartek/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar:/home/bartek/.m2/repository/commons-digester/commons-digester/1.8/commons-digester-1.8.jar:/home/bartek/.m2/repository/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar:/home/bartek/.m2/repository/commons-beanutils/commons-beanutils-core/1.8.0/commons-beanutils-core-1.8.0.jar:/home/bartek/.m2/repository/commons-net/commons-net/1.4.1/commons-net-1.4.1.jar:/home/bartek/.m2/repository/org/mortbay/jetty/jetty/6.1.26/jetty-6.1.26.jar:/home/bartek/.m2/repository/org/mortbay/jetty/servlet-api/2.5-20081211/servlet-api-2.5-20081211.jar:/home/bartek/.m2/repository/org/mortbay/jetty/jetty-util/6.1.26/jetty-util-6.1.26.jar:/home/bartek/.m2/repository/tomcat/jasper-runtime/5.5.12/jasper-runtime-5.5.12.jar:/home/bartek/.m2/repository/tomcat/jasper-compiler/5.5.12/jasper-compiler-5.5.12.jar:/home/bartek/.m2/repository/org/mortbay/jetty/jsp-api-2.1/6.1.14/jsp-api-2.1-6.1.14.jar:/home/bartek/.m2/repository/org/mortbay/jetty/jsp-2.1/6.1.14/jsp-2.1-6.1.14.jar:/home/bartek/.m2/repository/ant/ant/1.6.5/ant-1.6.5.jar:/home/bartek/.m2/repository/commons-el/commons-el/1.0/commons-el-1.0.jar:/home/bartek/.m2/repository/net/java/dev/jets3t/jets3t/0.7.1/jets3t-0.7.1.jar:/home/bartek/.m2/repository/net/sf/kosmosfs/kfs/0.3/kfs-0.3.jar:/home/bartek/.m2/repository/hsqldb/hsqldb/1.8.0.10/hsqldb-1.8.0.10.jar:/home/bartek/.m2/repository/oro/oro/2.0.8/oro-2.0.8.jar:/home/bartek/.m2/repository/org/eclipse/jdt/core/3.1.1/core-3.1.1.jar:/home/bartek/.m2/repository/org/codehaus/jackson/jackson-mapper-asl/1.0.1/jackson-mapper-asl-1.0.1.jar:/home/bartek/.m2/repository/org/apache/hbase/hbase/0.94.14/hbase-0.94.14.jar:/home/bartek/.m2/repository/com/yammer/metrics/metrics-core/2.1.2/metrics-core-2.1.2.jar:/home/bartek/.m2/repository/com/google/guava/guava/11.0.2/guava-11.0.2.jar:/home/bartek/.m2/repository/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar:/home/bartek/.m2/repository/com/github/stephenc/high-scale-lib/high-scale-lib/1.1.1/high-scale-lib-1.1.1.jar:/home/bartek/.m2/repository/commons-io/commons-io/2.1/commons-io-2.1.jar:/home/bartek/.m2/repository/commons-lang/commons-lang/2.5/commons-lang-2.5.jar:/home/bartek/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/home/bartek/.m2/repository/log4j/log4j/1.2.16/log4j-1.2.16.jar:/home/bartek/.m2/repository/org/apache/avro/avro/1.5.3/avro-1.5.3.jar:/home/bartek/.m2/repository/org/xerial/snappy/snappy-java/1.0.3.2/snappy-java-1.0.3.2.jar:/home/bartek/.m2/repository/org/apache/avro/avro-ipc/1.5.3/avro-ipc-1.5.3.jar:/home/bartek/.m2/repository/org/jboss/netty/netty/3.2.4.Final/netty-3.2.4.Final.jar:/home/bartek/.m2/repository/org/apache/velocity/velocity/1.7/velocity-1.7.jar:/home/bartek/.m2/repository/org/apache/zookeeper/zookeeper/3.4.5/zookeeper-3.4.5.jar:/home/bartek/.m2/repository/org/apache/thrift/libthrift/0.8.0/libthrift-0.8.0.jar:/home/bartek/.m2/repository/org/apache/httpcomponents/httpclient/4.1.2/httpclient-4.1.2.jar:/home/bartek/.m2/repository/org/apache/httpcomponents/httpcore/4.1.3/httpcore-4.1.3.jar:/home/bartek/.m2/repository/org/jruby/jruby-complete/1.6.5/jruby-complete-1.6.5.jar:/home/bartek/.m2/repository/org/mortbay/jetty/servlet-api-2.5/6.1.14/servlet-api-2.5-6.1.14.jar:/home/bartek/.m2/repository/org/codehaus/jackson/jackson-core-asl/1.8.8/jackson-core-asl-1.8.8.jar:/home/bartek/.m2/repository/org/codehaus/jackson/jackson-jaxrs/1.8.8/jackson-jaxrs-1.8.8.jar:/home/bartek/.m2/repository/org/codehaus/jackson/jackson-xc/1.8.8/jackson-xc-1.8.8.jar:/home/bartek/.m2/repository/org/slf4j/slf4j-api/1.4.3/slf4j-api-1.4.3.jar:/home/bartek/.m2/repository/org/slf4j/slf4j-log4j12/1.4.3/slf4j-log4j12-1.4.3.jar:/home/bartek/.m2/repository/org/jamon/jamon-runtime/2.3.1/jamon-runtime-2.3.1.jar:/home/bartek/.m2/repository/com/google/protobuf/protobuf-java/2.4.0a/protobuf-java-2.4.0a.jar:/home/bartek/.m2/repository/com/sun/jersey/jersey-core/1.8/jersey-core-1.8.jar:/home/bartek/.m2/repository/com/sun/jersey/jersey-json/1.8/jersey-json-1.8.jar:/home/bartek/.m2/repository/org/codehaus/jettison/jettison/1.1/jettison-1.1.jar:/home/bartek/.m2/repository/com/sun/xml/bind/jaxb-impl/2.2.3-1/jaxb-impl-2.2.3-1.jar:/home/bartek/.m2/repository/com/sun/jersey/jersey-server/1.8/jersey-server-1.8.jar:/home/bartek/.m2/repository/asm/asm/3.1/asm-3.1.jar:/home/bartek/.m2/repository/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar:/home/bartek/.m2/repository/javax/activation/activation/1.1/activation-1.1.jar:/home/bartek/.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar 
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib 
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:java.io.tmpdir=/tmp 
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:java.compiler=<NA> 
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:os.name=Linux 
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:os.arch=amd64 
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:os.version=3.16.0-34-generic 
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:user.name=bartek 
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:user.home=/home/bartek 
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:user.dir=/home/bartek/workspace/HBaseTester 
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=localhost:2181 sessionTimeout=180000 watcher=hconnection 
15/04/24 17:38:11 INFO zookeeper.RecoverableZooKeeper: The identifier of this process is [email protected] 
15/04/24 17:38:11 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error) 
15/04/24 17:38:11 INFO zookeeper.ClientCnxn: Socket connection established to localhost/127.0.0.1:2181, initiating session 
15/04/24 17:38:11 INFO zookeeper.ClientCnxn: Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x14cebe1a485000b, negotiated timeout = 40000 
15/04/24 17:38:12 INFO client.HConnectionManager$HConnectionImplementation: Closed zookeeper sessionid=0x14cebe1a485000b 
15/04/24 17:38:12 INFO zookeeper.ClientCnxn: EventThread shut down 
15/04/24 17:38:12 INFO zookeeper.ZooKeeper: Session: 0x14cebe1a485000b closed 

我HBase的(版本0.94.14)實例在本地主機上運行,​​而我不希望在分佈式模式下運行,上hdfs等等。只有一個實例。我可以通過在browswer中打開http://localhost:60010/來檢查它的狀態,並且一切似乎都沒問題。更重要的是,當我使用不同的應用程序(如Nutch或h-rider)時,一切工作正常(在我嘗試連接的HBase實例中)。我嘗試過不同的選項,例如設置hbase-env.sh中的環境變量$HBASE_HOME或設置爲export HBASE_MANAGES_ZK=true。在我的應用程序中獲得了包含在pom.xml中的相同版本,所以我可以說沒有版本衝突。

<dependency> 
    <groupId>org.apache.hbase</groupId> 
    <artifactId>hbase</artifactId> 
    <version>0.94.14</version> 
</dependency> 

$HBASE_HOME/conf/hbase-site.xml

<configuration> 
<property> 
    <name>hbase.rootdir</name> 
    <value>file:///home/bartek/hbase</value> 
</property> 
<property> 
    <name>hbase.cluster.distributed</name> 
    <value>false</value> 
</property> 

我怎樣才能使它運行?

編輯: 我已經改變了日誌調試,這就是我現在得到:

2015-05-04 14:31:42 DEBUG MutableMetricsFactory:42 - field org.apache.hadoop.metrics2.lib.MutableRate org.apache.hadoop.security.UserGroupInformation$UgiMetrics.loginSuccess with annotation @org.apache.hadoop.metrics2.annotation.Metric(always=false, about=, sampleName=Ops, type=DEFAULT, valueName=Time, value=[Rate of successful kerberos logins and latency (milliseconds)]) 
2015-05-04 14:31:42 DEBUG MutableMetricsFactory:42 - field org.apache.hadoop.metrics2.lib.MutableRate org.apache.hadoop.security.UserGroupInformation$UgiMetrics.loginFailure with annotation @org.apache.hadoop.metrics2.annotation.Metric(always=false, about=, sampleName=Ops, type=DEFAULT, valueName=Time, value=[Rate of failed kerberos logins and latency (milliseconds)]) 
2015-05-04 14:31:42 DEBUG MutableMetricsFactory:42 - field org.apache.hadoop.metrics2.lib.MutableRate org.apache.hadoop.security.UserGroupInformation$UgiMetrics.getGroups with annotation @org.apache.hadoop.metrics2.annotation.Metric(always=false, about=, sampleName=Ops, type=DEFAULT, valueName=Time, value=[GetGroups]) 
2015-05-04 14:31:42 DEBUG MetricsSystemImpl:231 - UgiMetrics, User and group related metrics 
2015-05-04 14:31:42 DEBUG KerberosName:88 - Kerberos krb5 configuration not found, setting default realm to empty 
2015-05-04 14:31:42 DEBUG Groups:278 - Creating new Groups object 
2015-05-04 14:31:42 DEBUG NativeCodeLoader:46 - Trying to load the custom-built native-hadoop library... 
2015-05-04 14:31:42 DEBUG NativeCodeLoader:55 - Failed to load native-hadoop with error: java.lang.UnsatisfiedLinkError: no hadoop in java.library.path 
2015-05-04 14:31:42 DEBUG NativeCodeLoader:56 - java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib 
2015-05-04 14:31:42 WARN NativeCodeLoader:62 - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 
2015-05-04 14:31:42 DEBUG PerformanceAdvisory:41 - Falling back to shell based 
2015-05-04 14:31:42 DEBUG JniBasedUnixGroupsMappingWithFallback:45 - Group mapping impl=org.apache.hadoop.security.ShellBasedUnixGroupsMapping 
2015-05-04 14:31:42 DEBUG Shell:396 - setsid exited with exit code 0 
2015-05-04 14:31:42 DEBUG Groups:91 - Group mapping impl=org.apache.hadoop.security.JniBasedUnixGroupsMappingWithFallback; cacheTimeout=300000; warningDeltaMs=5000 
2015-05-04 14:31:42 DEBUG UserGroupInformation:209 - hadoop login 
2015-05-04 14:31:42 DEBUG UserGroupInformation:144 - hadoop login commit 
2015-05-04 14:31:42 DEBUG UserGroupInformation:174 - using local user:UnixPrincipal: bartek 
2015-05-04 14:31:42 DEBUG UserGroupInformation:180 - Using user: "UnixPrincipal: bartek" with name bartek 
2015-05-04 14:31:42 DEBUG UserGroupInformation:190 - User entry: "bartek" 
2015-05-04 14:31:42 DEBUG UserGroupInformation:799 - UGI loginUser:bartek (auth:SIMPLE) 
2015-05-04 14:31:42 DEBUG ZKUtil:120 - hconnection opening connection to ZooKeeper with ensemble (localhost:2181) 
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:zookeeper.version=3.4.5-1392090, built on 09/30/2012 17:52 GMT 
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:host.name=localhost 
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:java.version=1.8.0_45 
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:java.vendor=Oracle Corporation 
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:java.home=/usr/lib/jvm/java-8-oracle/jre 
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:java.class.path=[...] // same as before 
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib 
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:java.io.tmpdir=/tmp 
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:java.compiler=<NA> 
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:os.name=Linux 
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:os.arch=amd64 
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:os.version=3.16.0-36-generic 
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:user.name=bartek 
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:user.home=/home/bartek 
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:user.dir=/var/my-proj 
2015-05-04 14:31:42 INFO ZooKeeper:438 - Initiating client connection, connectString=localhost:2181 sessionTimeout=180000 watcher=hconnection 
2015-05-04 14:31:42 DEBUG ClientCnxn:99 - zookeeper.disableAutoWatchReset is false 
2015-05-04 14:31:42 INFO RecoverableZooKeeper:104 - The identifier of this process is [email protected] 
2015-05-04 14:31:42 INFO ClientCnxn:966 - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error) 
2015-05-04 14:31:42 INFO ClientCnxn:849 - Socket connection established to localhost/127.0.0.1:2181, initiating session 
2015-05-04 14:31:42 DEBUG ClientCnxn:889 - Session establishment request sent on localhost/127.0.0.1:2181 
2015-05-04 14:31:42 INFO ClientCnxn:1207 - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x14d1ecf01b2000a, negotiated timeout = 40000 
2015-05-04 14:31:42 DEBUG ZooKeeperWatcher:294 - hconnection Received ZooKeeper Event, type=None, state=SyncConnected, path=null 
2015-05-04 14:31:42 DEBUG ZooKeeperWatcher:371 - hconnection-0x14d1ecf01b2000a connected 
2015-05-04 14:31:42 DEBUG ClientCnxn:815 - Reading reply sessionid:0x14d1ecf01b2000a, packet:: clientPath:null serverPath:null finished:false header:: 1,3 replyHeader:: 1,66,0 request:: '/hbase/hbaseid,F response:: s{13,13,1430740995346,1430740995346,0,0,0,0,55,0,13} 
2015-05-04 14:31:42 DEBUG ClientCnxn:815 - Reading reply sessionid:0x14d1ecf01b2000a, packet:: clientPath:null serverPath:null finished:false header:: 2,4 replyHeader:: 2,66,0 request:: '/hbase/hbaseid,F response:: #ffffffff000e35383437406c6f63616c686f737434313335376236322d346335622d343132362d386465392d343166643434646664636562,s{13,13,1430740995346,1430740995346,0,0,0,0,55,0,13} 
2015-05-04 14:31:42 DEBUG ZKUtil:1595 - hconnection-0x14d1ecf01b2000a Retrieved 36 byte(s) of data from znode /hbase/hbaseid; data=41357b62-4c5b-4126-8de9-41fd4... 
2015-05-04 14:31:42 DEBUG ClientCnxn:815 - Reading reply sessionid:0x14d1ecf01b2000a, packet:: clientPath:null serverPath:null finished:false header:: 3,3 replyHeader:: 3,66,0 request:: '/hbase/master,T response:: s{10,10,1430740994742,1430740994742,0,0,0,93765041680154624,50,0,10} 
2015-05-04 14:31:42 DEBUG ZKUtil:423 - hconnection-0x14d1ecf01b2000a Set watcher on existing znode /hbase/master 
2015-05-04 14:31:42 DEBUG ClientCnxn:815 - Reading reply sessionid:0x14d1ecf01b2000a, packet:: clientPath:null serverPath:null finished:false header:: 4,4 replyHeader:: 4,66,0 request:: '/hbase/master,T response:: #ffffffff000e35383437406c6f63616c686f7374006c6f63616c686f73742c34333133352c31343330373430393933323238,s{10,10,1430740994742,1430740994742,0,0,0,93765041680154624,50,0,10} 
2015-05-04 14:31:42 DEBUG ZKUtil:1595 - hconnection-0x14d1ecf01b2000a Retrieved 31 byte(s) of data from znode /hbase/master and set watcher; \x00\x00localhost,43135,14307... 
2015-05-04 14:31:42 DEBUG ClientCnxn:815 - Reading reply sessionid:0x14d1ecf01b2000a, packet:: clientPath:null serverPath:null finished:false header:: 5,3 replyHeader:: 5,66,0 request:: '/hbase/root-region-server,T response:: s{30,30,1430741001288,1430741001288,0,0,0,0,48,0,30} 
2015-05-04 14:31:42 DEBUG ZKUtil:423 - hconnection-0x14d1ecf01b2000a Set watcher on existing znode /hbase/root-region-server 
2015-05-04 14:31:42 DEBUG ClientCnxn:815 - Reading reply sessionid:0x14d1ecf01b2000a, packet:: clientPath:null serverPath:null finished:false header:: 6,4 replyHeader:: 6,66,0 request:: '/hbase/root-region-server,T response:: #ffffffff000e35383437406c6f63616c686f73746c6f63616c686f73742c33353931382c31343330373430393933373635,s{30,30,1430741001288,1430741001288,0,0,0,0,48,0,30} 
2015-05-04 14:31:42 DEBUG ZKUtil:1595 - hconnection-0x14d1ecf01b2000a Retrieved 29 byte(s) of data from znode /hbase/root-region-server and set watcher; localhost,35918,1430740993765 
2015-05-04 14:31:42 DEBUG HBaseRPC:102 - Using RpcEngine: org.apache.hadoop.hbase.ipc.WritableRpcEngine 
2015-05-04 14:31:42 DEBUG HBaseClient:868 - The ping interval is60000ms. 
2015-05-04 14:31:42 DEBUG ClientCnxn:815 - Reading reply sessionid:0x14d1ecf01b2000a, packet:: clientPath:null serverPath:null finished:false header:: 7,3 replyHeader:: 7,66,0 request:: '/hbase,F response:: s{2,2,1430740993557,1430740993557,0,12,0,0,0,12,30} 
2015-05-04 14:31:42 DEBUG ClientCnxn:815 - Reading reply sessionid:0x14d1ecf01b2000a, packet:: clientPath:null serverPath:null finished:false header:: 8,4 replyHeader:: 8,66,0 request:: '/hbase/root-region-server,T response:: #ffffffff000e35383437406c6f63616c686f73746c6f63616c686f73742c33353931382c31343330373430393933373635,s{30,30,1430741001288,1430741001288,0,0,0,0,48,0,30} 
2015-05-04 14:31:42 DEBUG ZKUtil:1595 - hconnection-0x14d1ecf01b2000a Retrieved 29 byte(s) of data from znode /hbase/root-region-server and set watcher; localhost,35918,1430740993765 
2015-05-04 14:31:42 DEBUG HConnectionManager$HConnectionImplementation:987 - Looked up root region location, connection=org.apache.h[email protected]7daa0fbd; serverName=localhost,35918,1430740993765 
2015-05-04 14:31:42 DEBUG HBaseClient:436 - Connecting to [email protected] 
2015-05-04 14:31:42 DEBUG HBaseClient:739 - closing ipc connection to localhost/127.0.0.1:35918: Could not set up IO Streams 
java.io.IOException: Could not set up IO Streams 
    at org.apache.hadoop.hbase.ipc.HBaseClient$Connection.setupIOstreams(HBaseClient.java:456) 
    at org.apache.hadoop.hbase.ipc.HBaseClient.getConnection(HBaseClient.java:1141) 
    at org.apache.hadoop.hbase.ipc.HBaseClient.call(HBaseClient.java:988) 
    at org.apache.hadoop.hbase.ipc.WritableRpcEngine$Invoker.invoke(WritableRpcEngine.java:87) 
    at com.sun.proxy.$Proxy21.getProtocolVersion(Unknown Source) 
    at org.apache.hadoop.hbase.ipc.WritableRpcEngine.getProxy(WritableRpcEngine.java:141) 
    at org.apache.hadoop.hbase.ipc.HBaseRPC.waitForProxy(HBaseRPC.java:208) 
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getHRegionConnection(HConnectionManager.java:1473) 
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getHRegionConnection(HConnectionManager.java:1432) 
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getHRegionConnection(HConnectionManager.java:1419) 
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:1102) 
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:997) 
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:1099) 
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:1001) 
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:958) 
    at org.apache.hadoop.hbase.client.HTable.finishSetup(HTable.java:251) 
    at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:155) 
    at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:129) 
    at com.company.my.proj.test.core.HBaseTest.connectDirect(HBaseTest.java:42) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:497) 
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) 
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) 
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) 
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) 
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) 
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) 
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) 
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) 
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) 
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) 
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) 
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363) 
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) 
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) 
Caused by: java.lang.NoSuchMethodError: org.apache.hadoop.net.NetUtils.getInputStream(Ljava/net/Socket;)Ljava/io/InputStream; 
    at org.apache.hadoop.hbase.ipc.HBaseClient$Connection.setupIOstreams(HBaseClient.java:439) 
    ... 41 more 

回答

0

我覺得我得到了解決,在我的OS關閉IPv6 (Ubuntu在這裏)幫助。它可以這樣做:https://askubuntu.com/a/484487/309788,但記得重新啓動你的系統,只是簡單的配置是不夠的,在我的情況。

0

試試這個:

public static void main(String[] args) throws IOException, Exception{ 

     Configuration conf = HBaseConfiguration.create(); 
     conf.set("hbase.master", "localhost:60000"); 
     conf.set("hbase.zookeeper.quorum","localhost"); 
     conf.set("hbase.zookeeper.property.clientPort", "2181"); 


     HTable table = new HTable(conf, "mytable"); 


     Get g = new Get(Bytes.toBytes("row1")); 

     Result result = table.get(g); 


     byte[]value=result.getValue(Bytes.toBytes("Columnfam1"),Bytes.toBytes("column"); 

     String R = Bytes.toString(value); 

     System.out.println(R); 
     table.close(); 

    } 
+0

有什麼問題? –

+0

我已經添加了DEBUG日誌。 – wbk