hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vamshi krishna <vamshi2...@gmail.com>
Subject writing data to hbase from java code in eclipse
Date Thu, 22 Sep 2011 06:38:40 GMT
Hi ,
i am trying to cretae and write data to a table in hbase. For that i am
using hadoop-0.20.2 and hbase -0.90.4 single machine and pseudo distributed
mode. In eclipse helios, i write on e samll program
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.util.Bytes;

import java.io.IOException;

public class PutExample {

    /**
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        Configuration conf = HBaseConfiguration.create();
         HTable table = new HTable(conf, "testtable");
         Put put = new Put(Bytes.toBytes("row1"));
         put.add(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"),
                  Bytes.toBytes("val1"));
         put.add(Bytes.toBytes("colfam1"), Bytes.toBytes("qual2"),
                  Bytes.toBytes("val2"));
         table.put(put);

    }

}

My hadoop , and hbase shell are working properly.i added
hadoop-0.20.2-core.jar, hbase-0.90.4.jar, commons-logging-1.0.4-api.jar,
log4j-1.4.15.jar, zookeeper-3.3.2.jar in to addexternal jars of buildpath in
the hbase project buildpath. I added HBASE_HOME/conf folder in
addclassfolder option of buildpath.
 i selected hbase project ->right click-> run as java application
i got  followong error.

11/09/22 12:08:11 INFO zookeeper.ZooKeeper: Client
environment:zookeeper.version=3.3.2-1031432, built on 11/05/2010 05:32 GMT
11/09/22 12:08:11 INFO zookeeper.ZooKeeper: Client environment:host.name
=vamshi-laptop
11/09/22 12:08:11 INFO zookeeper.ZooKeeper: Client
environment:java.version=1.6.0_26
11/09/22 12:08:11 INFO zookeeper.ZooKeeper: Client
environment:java.vendor=Sun Microsystems Inc.
11/09/22 12:08:11 INFO zookeeper.ZooKeeper: Client
environment:java.home=/usr/lib/jvm/java-6-sun-1.6.0.26/jre
11/09/22 12:08:11 INFO zookeeper.ZooKeeper: Client
environment:java.class.path=/home/hduser/workspace/InsertHbase/build/eclipse-classes:/home/hduser/Documents/HBASE_SOFTWARE/hbase-0.90.2.jar:/usr/local/hadoop-0.20.2/hadoop-0.20.2-core.jar:/home/hduser/Documents/HBASE_SOFTWARE/hbase-0.90.4/conf:/usr/local/hadoop-0.20.2/lib/commons-logging-api-1.0.4.jar:/usr/local/hadoop-0.20.2/lib/log4j-1.2.15.jar:/home/hduser/Documents/HBASE_SOFTWARE/hbase-0.90.4/lib/zookeeper-3.3.2.jar
11/09/22 12:08:11 INFO zookeeper.ZooKeeper: Client
environment:java.library.path=/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/i386/server:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/../lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/i386/client:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/i386::/usr/java/packages/lib/i386:/lib:/usr/lib
11/09/22 12:08:11 INFO zookeeper.ZooKeeper: Client
environment:java.io.tmpdir=/tmp
11/09/22 12:08:11 INFO zookeeper.ZooKeeper: Client
environment:java.compiler=<NA>
11/09/22 12:08:11 INFO zookeeper.ZooKeeper: Client environment:os.name=Linux
11/09/22 12:08:11 INFO zookeeper.ZooKeeper: Client environment:os.arch=i386
11/09/22 12:08:11 INFO zookeeper.ZooKeeper: Client
environment:os.version=2.6.32-33-generic
11/09/22 12:08:11 INFO zookeeper.ZooKeeper: Client environment:user.name
=hduser
11/09/22 12:08:11 INFO zookeeper.ZooKeeper: Client
environment:user.home=/home/hduser
11/09/22 12:08:11 INFO zookeeper.ZooKeeper: Client
environment:user.dir=/home/hduser/workspace/InsertHbase
11/09/22 12:08:11 INFO zookeeper.ZooKeeper: Initiating client connection,
connectString=localhost:2181 sessionTimeout=180000 watcher=hconnection
11/09/22 12:08:11 INFO zookeeper.ClientCnxn: Opening socket connection to
server localhost/127.0.0.1:2181
11/09/22 12:08:11 INFO zookeeper.ClientCnxn: Socket connection established
to localhost/127.0.0.1:2181, initiating session
11/09/22 12:08:11 INFO zookeeper.ClientCnxn: Session establishment complete
on server localhost/127.0.0.1:2181, sessionid = 0x1328fb0fd440005,
negotiated timeout = 40000
22 Sep, 2011 12:08:11 PM
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation
prefetchRegionCache
WARNING: Encountered problems when prefetch META table:
org.apache.hadoop.hbase.TableNotFoundException: Cannot find row in .META.
for table: testtable, row=testtable,,99999999999999
    at
org.apache.hadoop.hbase.client.MetaScanner.metaScan(MetaScanner.java:136)
    at
org.apache.hadoop.hbase.client.MetaScanner.metaScan(MetaScanner.java:95)
    at
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.prefetchRegionCache(HConnectionManager.java:648)
    at
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:702)
    at
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:593)
    at
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:558)
    at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:171)
    at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:145)
    at PutExample.main(PutExample.java:19)
Exception in thread "main" org.apache.hadoop.hbase.TableNotFoundException:
testtable
    at
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:724)
    at
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:593)
    at
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:558)
    at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:171)
    at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:145)
    at PutExample.main(PutExample.java:19)



please anyone help me, where i went wrong?

-- 
*Regards*
*
Vamshi Krishna
*

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message