【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這一配置選項,若是沒有,加上後進行從新包,也能夠參考第一種異常解決方案操做。