HBase exception: Hbase-default.xml file seems to is for and version of the HBase solution
In the recent creation of the configuration object using the HBase Java Client Connection HBase Server, an exception was encountered Hbase-default.xml file seems to is for and version of HBase, After looking for information and reading HBase related source code, this kind of abnormal solution to do a summary.
Cause of abnormal appearance
When the HBase client creates the configuration object, it needs to use the Hbase-*.jar package, where the * section identifies the HBase version number of the connection:
[root@xxxxxx]$ ls Hbase-*.jar
Hbase-0.92.1.jar
Then, in the hbase-default.xml of the Hbase-*.jar package, there is a configuration item about the HBase default version number:
<property skipindoc= "true" >
<name>hbase.defaults.for.version</name>
<value> 0.92.1</value>
<description> This
defaults file is compiled for version 0.92.1. This variable was used to make
sure that a user doesn ' t have ' the ' the Hbase-default.xml '
C7/></description>
</property>
When the client starts, The version number specified in the JAR package name and the Hbase.defaults.for.version option set in Hbase-default.xml in the jar package are first checked for consistency, which is normally consistent and no exception thrown (as in the example above).
Otherwise, the following exception is reported if the jar package name specifies a version number less than the Hbase.defaults.for.version specified version number:
Java.lang.runtimeexception:hbase-default.xml file seems to is for and old version of HBase ...
......
How to solve the exception
The first case
Unusual phenomena:
caused By:java.lang.runtimeexception:hbase-default.xml file seems to is for and old version of HBase (@@ zzfcthotfixz @@@), th is version is 0.92.1
At Org.apache.hadoop.hbase.HBaseConfiguration.checkDefaultsVersion (hbaseconfiguration.java:68)
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/database/extra/
At Org.apache.hadoop.hbase.HBaseConfiguration.addHbaseResources (hbaseconfiguration.java:100)
This is because the Hbase.defaults.for.version configuration entry in Hbase-default.xml is not properly replaced with the version number specified by Maven when it is packaged, and you can unlock hbase-*. The jar opens Hbase-default.xml for verification. Workaround:
1, open the HBase Maven project Pom.properties file, determine whether the version=0.92.1 configuration option is specified, if not, and then repackaged. It was suggested that the following parts of the Pom.xml be StackOverflow:
<execution>
<phase>process-resources</phase>
<configuration>
<target >
<replace file= "${project.build.outputdirectory}/hbase-default.xml" token= @@ zzfcthotfixz @@@ "value=" ${ project.version} " />
</target>
</configuration>
<goals>
<goal> run</goal>
</goals>
</execution>
Change the target to tasks:
<execution>
<phase>process-resources</phase>
<configuration>
<tasks>
<replace file= "${project.build.outputdirectory}/hbase-default.xml" token= @@ zzfcthotfixz @@@ "value=" ${ project.version} " />
</tasks>
</configuration>
<goals>
<goal> run</goal>
</goals>
</execution>
A review of the Maven Antrun plugin for tasks and Target explains:
Target Plexusconfiguration 1.5 The XML for the Ant target. Can add anything you can add between <target> and </target> in a build.xml.
Tasks plexusconfiguration-deprecated. Use target instead
Tasks are deprecated, and target is recommended. StackOverflow the author said that the situation may be due to the Antrun plug-in version of the low reasons (personal guessing, not actually validated). If you have determined that the @@ ZZFCTHOTFIXZ @@@ 被 successfully replaced, you do not have to do the above.
2, another way is to directly extract the jar package after modifying the Hbase-default.xml, and then back into a jar package.
Second case
Unusual phenomena:
caused By:java.lang.runtimeexception:hbase-default.xml file seems to is for and old version of the HBase (*.**.*), this vers Ion is 0.92.1
At Org.apache.hadoop.hbase.HBaseConfiguration.checkDefaultsVersion (hbaseconfiguration.java:68)
At Org.apache.hadoop.hbase.HBaseConfiguration.addHbaseResources (hbaseconfiguration.java:100)
This is because the Hbase.defaults.for.version configuration entry in Hbase-default.xml is inconsistent with the specified version number in the Hbase-*.jar name. Workaround:
1, open the Engineering directory under the Hbase-site.xml, the Hbase.defaults.for.version.skip configured to True, ignoring the default version of the check:
<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 is useful in contexts and 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
se EMS to being for and old version of the HBase (0.92.1), this
version is X.x.x-snapshot "
</description>
</ Property>
2, the two changes to a consistent version number, specific reference to the first case method.
Third situation
Unusual phenomena:
caused By:java.lang.runtimeexception:hbase-default.xml file seems to is for and old version of HBase (null), this Versio N is 0.92.1
At Org.apache.hadoop.hbase.HBaseConfiguration.checkDefaultsVersion (hbaseconfiguration.java:68)
At Org.apache.hadoop.hbase.HBaseConfiguration.addHbaseResources (hbaseconfiguration.java:100)
This is because the default version number was not obtained because the load Hbase-default.xml failed. This situation is related to the actual environment, and here are some possible solutions to try:
1, delete the Java Engineering directory of hbase-default.xml files;
2, refer to HBase mail list search results: click here.