spring-attic / spring-hadoop-samples

Spring Hadoop Samples
Apache License 2.0
492 stars 466 forks source link

Can I have a working sample for spring hbase using hbaseTemplate with lastest stable hBase build? #24

Closed xhe closed 9 years ago

xhe commented 9 years ago

I am a newbie for Hbase and I want to continue to use spring solution, hBaseTemplate to access HBase. But I tested a lot of times and can never be successful in doing so. This is what I did. The sample I am using is: https://github.com/spring-projects/spring-data-book/tree/master/hadoop/hbase

I am using latest stable HBase build, version 1.0.1.1 When I start UserApp, I got this error:

 Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userUtils' defined in file [/Users/fhe/spring/spring-data-book/hadoop/hbase/target/classes/com/oreilly/springdata/hadoop/hbase/UserUtils.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a host:port pair: PBUF

192.168.1.75��ݠ���)�}
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:197)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:172)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:158)
    at com.oreilly.springdata.hadoop.hbase.UserApp.main(UserApp.java:30)

So I google this error: Not a host:port pair: PBUF

checking the POM file,

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <spring.hadoop.version>1.0.0.RELEASE</spring.hadoop.version>
        <hadoop.version>1.0.1</hadoop.version>
        <hbase.version>0.92.1</hbase.version>
        <log4j.version>1.2.17</log4j.version>
    </properties>

People said it is because version is different from client and server. so I donwload hbaseServer 0.92.1, start HBaseServer and then start project again, now error is:

09:22:32.259 [main-SendThread(localhost:2181)] WARN  org.apache.zookeeper.ClientCnxn - Session 0x14e5f064fea0003 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.6.0_65]
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:599) ~[na:1.6.0_65]
    at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:286) ~[zookeeper-3.4.3.jar:3.4.3-1240972]
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1035) ~[zookeeper-3.4.3.jar:3.4.3-1240972]
09:22:32.503 [main-SendThread(localhost:2181)] INFO  org.apache.zookeeper.ClientCnxn - Opening socket connection to server /127.0.0.1:2181
09:22:32.504 [main-SendThread(localhost:2181)] WARN  o.a.z.client.ZooKeeperSaslClient - SecurityException: java.lang.SecurityException: Unable to locate a login configuration occurred when trying to find JAAS configuration.
09:22:32.504 [main-SendThread(localhost:2181)] INFO  o.a.z.client.ZooKeeperSaslClient - Client will not SASL-authenticate because the default JAAS configuration section 'Client' could not be found. If you are not using SASL, you may ignore this. On the other hand, if you expected SASL to work, please fix your JAAS configuration.
09:22:32.505 [main-SendThread(localhost:2181)] WARN  org.apache.zookeeper.ClientCnxn - Session 0x14e5f064fea0002 for server null, unexpected error, closing socket connection and attempting reconnect

Even if I am using Hbase Shell, it is throwing a lot exceptions, so I gave up old version of hBase server.

I tried to use same hBaseClient in the POM to match latest HBase Server, 1.0.1.1, but it is either jar not available error, or some other major minor version exceptions.

Can anyone who has such experiences tell me how you fixed it and use hbaseTemplate to work with latest stable hBaseBuild? How do you config the spring project etc? Can you show me your working solution?

Thanks very much.

chang-chao commented 9 years ago

As is shown in the log,the hbase client cannot conenct to zookeeper port(localhost:2181). Did you start hbase in the same machine with the client? If not,change https://github.com/spring-projects/spring-data-book/blob/master/hadoop/hbase/src/main/resources/hbase.properties to relfect your hbase server configuration.

By the way,I don't think this is not the proper place to ask a question about spring-data-book project. Maybe you should post your question to stackoverflow or somewhere else.

trisberg commented 9 years ago

Created hbase example based on the Spring Data book example. Updated to current versions. Continue discussion on StackOverflow - http://stackoverflow.com/questions/31232486/spring-hbasetemplate-throws-java-lang-illegalargumentexception-not-a-hostport