[转] HBase异常:hbase-default.xml file seems to be for an old version of HBase

【From】 https://blog.yoodb.com/yoodb/article/detail/157java

 

使用HBase Java Client链接HBase服务端建立Configuration对象时遇到了此类错误,“hbase-default.xml file seems to be for and old version of HBase的异常”,通过查询资料总结经验。apache

 

分析异常出现的缘由maven

 

HBase客户端建立Configuration对象时,须要使用hbase-*.jar包,其中*部分标识了链接的HBase版本号:ide

[root@xxxxxx]$ ls hbase-*.jar
hbase-0.92.1.jar

在hbase-*.jar包的hbase-default.xml中,有一个关于HBase默认版本号的配置项以下:oop

<property skipInDoc="true">
    <name>hbase.defaults.for.version</name>
    <value>0.92.1</value>
    <description>
    This defaults file was compiled for version 0.92.1. This variable is used
    to make sure that a user doesn't have an old version of hbase-default.xml on the
    classpath.    </description>
  </property>

当客户端启动时,首先会检测此包中所指定的版本号以及hbase-default.xml中设置的hbase.defaults.for.version版本号是否一致。正常状况下两者是一致,不会抛出Exception。this

若是指定版本号小于hbase.defaults.for.version指定版本号,就会抛出以下异常:spa

Exception in thread "main" java.lang.RuntimeException: hbase-default.xml file seems to be for and old version of HBase (@@@VERSION@@@), this version is 0.92.1
        at org.apache.Hadoop.hbase.HBaseConfiguration.checkDefaultsVersion(HBaseConfiguration.java:68)
        at org.apache.hadoop.hbase.HBaseConfiguration.addHbaseResources(HBaseConfiguration.java:100)
        at org.apache.hadoop.hbase.HBaseConfiguration.create(HBaseConfiguration.java:111)
        at org.apache.hadoop.hbase.util.HBaseConfTool.main(HBaseConfTool.java:38)
Exception in thread "main" java.lang.RuntimeException: hbase-default.xml file seems to be for and old version of HBase (@@@VERSION@@@), this version is 0.92.1
...

 

解决方式xml

 

异常状况一:对象

Caused by: java.lang.RuntimeException: hbase-default.xml file seems to be for and old version of HBase (*.**.*), this version is 0.92.1
        at org.apache.hadoop.hbase.HBaseConfiguration.checkDefaultsVersion(HBaseConfiguration.java:68)
        at org.apache.hadoop.hbase.HBaseConfiguration.addHbaseResources(HBaseConfiguration.java:100)

缘由是hbase-default.xml中的hbase.defaults.for.version配置项与hbase-*.jar名中指定版本号不一致,打开工程目录下的hbase-site.xml,将hbase.defaults.for.version.skip配置为true,忽略默认版本的检查代码以下:blog

<property>
    <name>hbase.defaults.for.version.skip</name>
    <value>true</value>
    <description>
    Set to true to skip the 'hbase.defaults.for.version' check.
    Setting this to true can be useful in contexts other than
    the other side of a maven generation; i.e. running in an
    ide.  You'll want to set this boolean to true to avoid
    seeing the RuntimException complaint: "hbase-default.xml file
    seems to be for and old version of HBase (0.92.1), this
    version is X.X.X-SNAPSHOT"    </description>
  </property>

 

异常状况二:

Caused by: java.lang.RuntimeException: hbase-default.xml file seems to be for and old version of HBase (null), this version is 0.92.1
        at org.apache.hadoop.hbase.HBaseConfiguration.checkDefaultsVersion(HBaseConfiguration.java:68)
        at org.apache.hadoop.hbase.HBaseConfiguration.addHbaseResources(HBaseConfiguration.java:100)

加载hbase-default.xml失败没有获取默认的版本号,因实际状况而定试一试删除Java的工程目录下的hbase-default.xml文件。

 

异常状况三:(maven下载jar包致使)

Caused by: java.lang.RuntimeException: hbase-default.xml file seems to be for and old version of HBase (@@@VERSION@@@), this version is 0.92.1
        at org.apache.hadoop.hbase.HBaseConfiguration.checkDefaultsVersion(HBaseConfiguration.java:68)
        at org.apache.hadoop.hbase.HBaseConfiguration.addHbaseResources(HBaseConfiguration.java:100)

hbase-default.xml中的hbase.defaults.for.version配置项在打包时没有被正常替换成maven指定的版本号打开HBase maven工程的pom.properties文件,肯定是否指定了version=0.92.1这一配置选项,若是没有,加上后进行从新包,也能够参考第一种异常解决方案操做。

相关文章
相关标签/搜索