Hbase exception: hbase-default.xml file seems to be for and old version of hbase Solution

Source: Internet
Author: User

Recently in the use of hbase Java client to connect to the hbase server to create configuration object, encountered a hbase-default.xml file seems to be and old version of hbase exception, after searching for information and reading hbase related source code, summarize the solutions for such exceptions.

Causes of exceptions

When creating a configuration object on the hbase client, you must use the hbase-*. jar package. The * Part of the package indicates the hbase version number of the connection:

 
[Root @ xxxxxx] $LsHbase-*. Jarhbase-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:

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

When the client starts, first check the version number specified in the jar package name and the hbase set in the hbase-default.xml in the jar package. defaults. for. whether the Version options are consistent. Normally, the two are consistent and no exception is thrown (as shown in the preceding example ).

Otherwise, if the specified version number of the jar package name is earlier than hbase. defaults. For. version, the following exception is reported:

 
Java. Lang. runtimeexception: hbase-Default. Xml file seems to beForAnd old version of hbase ......
......
Solution to exceptions: Case 1

Exception:

 
Caused by: Java. Lang. runtimeexception: hbase-Default. Xml file seems to beForAnd old version of hbase (@ Version @@@),ThisVersion is 0.92.1At org. Apache. hadoop. hbase. hbaseconfiguration. checkdefaultsversion (hbaseconfiguration. Java:68) At org. Apache. hadoop. hbase. hbaseconfiguration. addhbaseresources (hbaseconfiguration. Java:100)

This is because hbase-DefaultThe hbase. defaults. For. Version configuration item in. XML is not properly replaced with the version specified by Maven during packaging. You can unlock hbase-*. jar to open hbase-Default. XML for verification. Solution:

1. Open the Pom. properties file of the hbase Maven project and check whether the configuration option version = 0.92.1 is specified. If not, add the option and repackage it. On stackoverflow, it is recommended that you set the following section in POM. xml:

          <  Execution  >              <  Phase  > Process-Resources </  Phase  >              <  Configuration  >                <  Target  >                  <  Replace File  = "$ {Project. Build. outputdirectory}/hbase-default.xml"  Token  = "@ Version @@@"  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 = "@ Version @@@"  Value  = "$ {Project. Version }"   />                </  Tasks  >              </  Configuration  >              <  Goals  >                <  Goal  > Run</  Goal  >              </  Goals  >            </  Execution  > 

After reading Maven antrun plugin's explanation about tasks and target:

Target plexusconfiguration 1.5 the XML for the ant target. You can add anything you can add<Target>And</Target>In a build. xml. Tasks plexusconfiguration-deprecated. Use target instead

Target is not recommended for tasks. According to the author on stackoverflow, it may be because of a low version of The antrun plug-in (I guess it has not been verified ). If you have confirmed that @ version @ is successfully replaced, you do not need to perform the preceding operations.

2, another way is to directly decompress the jar package, modify the hbase-default.xml, and then re-package into a jar package.

Case 2

Exception:

Caused by: Java. Lang. runtimeexception: hbase-Default. Xml file seems to beForAnd old version of hbase (*.**.*),ThisVersion is 0.92.1At org. Apache. hadoop. hbase. hbaseconfiguration. checkdefaultsversion (hbaseconfiguration. Java:68) At org. Apache. hadoop. hbase. hbaseconfiguration. addhbaseresources (hbaseconfiguration. Java:100)

This is because hbase-DefaultThe hbase. defaults. For. Version configuration item in. XML is inconsistent with the version specified in hbase-*. Jar name. Solution:

1. Open the hbase-site.xml under the project directory, configure hbase. defaults. For. version. Skip to true, ignore the check for the default version:

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

2. Change the two to the same version number. For details, refer to the method in the first case.

Case 3

Exception:

Caused by: Java. Lang. runtimeexception: hbase-Default. Xml file seems to beForAnd old version of hbase (Null),ThisVersion is 0.92.1At org. Apache. hadoop. hbase. hbaseconfiguration. checkdefaultsversion (hbaseconfiguration. Java:68) At org. Apache. hadoop. hbase. hbaseconfiguration. addhbaseresources (hbaseconfiguration. Java:100)

This situation is caused by loading hbase-Default. Xml failed to get the default version number. This situation is related to the actual environment. The following are some solutions that can be tried:

1. Delete the hbase-default.xml file under the Java project directory;

2. Refer to the hbase Mail List Search Result: click here.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.