spring hbasetemplate抛出java.lang.illegalargumentexception:不是host:port pair:pbuf

0h4hbjxa  于 2021-06-09  发布在  Hbase
关注(0)|答案(1)|浏览(519)

我是hbase的新手,我想继续使用spring解决方案hbasetemplate来访问hbase。但我做了很多次测试,都不可能成功。我就是这么做的。我使用的样本是:https://github.com/spring-projects/spring-data-book/tree/master/hadoop/hbase
我正在使用最新的稳定hbase版本1.0.1.1启动userapp时,出现以下错误:

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)

所以我用谷歌搜索这个错误:不是host:port pair:pbuf
检查pom文件,

<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>

人们说这是因为版本不同于客户端和服务器。所以我加载了hbaseserver0.92.1,启动hbaseserver,然后再次启动project,现在的错误是:

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

即使我使用的是hbase shell,它也抛出了很多异常,所以我放弃了旧版本的hbase服务器。
我尝试在pom中使用同一个hbaseclient来匹配最新的hbase服务器1.0.1.1,但这不是jarnotavailable错误,就是一些其他主要的次要版本异常。
有这样经验的人能告诉我您是如何修复它并使用hbasetemplate处理最新的稳定hbasebuild的吗?如何配置spring项目等?你能给我看看你的工作方案吗?
非常感谢。
连接字符串:这是在示例中使用的上下文:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:hdp="http://www.springframework.org/schema/hadoop"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/hadoop http://www.springframework.org/schema/hadoop/spring-hadoop.xsd">

    <context:property-placeholder location="hbase.properties"/>

    <context:component-scan base-package="com.oreilly.springdata.hadoop.hbase"/>

    <hdp:configuration id="hadoopConfiguration">
      fs.default.name=hdfs://localhost:9000
    </hdp:configuration>

    <hdp:hbase-configuration configuration-ref="hadoopConfiguration" zk-quorum="${hbase.host}" zk-port="${hbase.port}"/>

    <bean id="hbaseTemplate" class="org.springframework.data.hadoop.hbase.HbaseTemplate">
        <property name="configuration" ref="hbaseConfiguration"/>
    </bean>

</beans>

我尝试将hadoop依赖性更改为:

<dependency>
            <groupId>org.apache.hbase</groupId>
            <artifactId>hbase-client</artifactId>
            <version>1.0.1.1</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

现在pbuf错误消失了,相反,我有一个错误:

Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [META-INF/spring/application-context.xml]; nested exception is org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class [org.springframework.data.hadoop.config.HadoopNamespaceHandler] for namespace [http://www.springframework.org/schema/hadoop]: problem with handler class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: org/springframework/data/hadoop/config/HadoopNamespaceHandler : Unsupported major.minor version 51.0
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:123)
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
    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)
s71maibg

s71maibg1#

我看到你在github上的评论,所以我把spring数据手册中的hbase示例应用程序添加到spring for apache hadoop示例repo中-https://github.com/spring-projects/spring-hadoop-samples/tree/master/hbase
同时,我更新了以下版本的最新版本:

spring.hadoop.version: 2.2.0.RELEASE
hadoop.version: 2.6.0
hbase.version: 0.98.5-hadoop2

稍后,我将使用最新的稳定hbase版本(1.0.1.1)对此进行一次尝试。在为apachehadoop项目构建spring时,我们使用了0.98.5-hadoop2。

相关问题