2012-03-31 13 views
3

私はhbaseをjavaで動作させようとしています。私はそれを助けてください例外を与える次のコードを試してみました。Hbaseの例外org/apache/commons/configuration/Configurationが見つかりません

package com.bee.searchlib.test; 

import org.apache.hadoop.conf.Configuration; 
import org.apache.hadoop.hbase.HBaseConfiguration; 
import org.apache.hadoop.hbase.HColumnDescriptor; 
import org.apache.hadoop.hbase.HTableDescriptor; 
import org.apache.hadoop.hbase.MasterNotRunningException; 
import org.apache.hadoop.hbase.client.HBaseAdmin; 
import org.apache.hadoop.hbase.client.HTable; 

public class Test { 

    public static void main(String args[]) throws Exception { 

     Configuration config = HBaseConfiguration.create(); 
     HBaseAdmin admin = null; 
     try { 
      // HBaseAdmin is where all the "DDL" like operations take place in 
      // HBase 
      admin = new HBaseAdmin(config); 
     } catch (MasterNotRunningException e) { 
      throw new Exception(
        "Could not setup HBaseAdmin as no master is running, did you start HBase?..."); 
     } 

     if (!admin.tableExists("testTable")) { 
      admin.createTable(new HTableDescriptor("testTable")); 

      // disable so we can make changes to it 
      admin.disableTable("testTable"); 

      // lets add 2 columns 
      admin.addColumn("testTable", new HColumnDescriptor("firstName")); 
      admin.addColumn("testTable", new HColumnDescriptor("lastName")); 

      // enable the table for use 
      admin.enableTable("testTable"); 

     } 

     // get the table so we can use it in the next set of examples 
     HTable table = new HTable(config, "testTable"); 
    } 
} 

excepion:ビルド・パス Hadoopのコア-1.0.0.jar HBaseの-0.92.1.jar のlog4j-1.2.16.jar コモンズ・ログで

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/configuration/Configuration 
    at org.apache.hadoop.metrics2.lib.DefaultMetricsSystem.<init>(DefaultMetricsSystem.java:37) 
    at org.apache.hadoop.metrics2.lib.DefaultMetricsSystem.<clinit>(DefaultMetricsSystem.java:34) 
    at org.apache.hadoop.security.UgiInstrumentation.create(UgiInstrumentation.java:51) 
    at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:209) 
    at org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:177) 
    at org.apache.hadoop.security.UserGroupInformation.isSecurityEnabled(UserGroupInformation.java:229) 
    at org.apache.hadoop.security.KerberosName.<clinit>(KerberosName.java:83) 
    at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:202) 
    at org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:177) 
    at org.apache.hadoop.security.UserGroupInformation.isSecurityEnabled(UserGroupInformation.java:229) 
    at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:428) 
    at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:414) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at org.apache.hadoop.hbase.util.Methods.call(Methods.java:37) 
    at org.apache.hadoop.hbase.security.User.call(User.java:586) 
    at org.apache.hadoop.hbase.security.User.callStatic(User.java:576) 
    at org.apache.hadoop.hbase.security.User.access$400(User.java:50) 
    at org.apache.hadoop.hbase.security.User$SecureHadoopUser.<init>(User.java:393) 
    at org.apache.hadoop.hbase.security.User$SecureHadoopUser.<init>(User.java:388) 
    at org.apache.hadoop.hbase.security.User.getCurrent(User.java:139) 
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionKey.<init>(HConnectionManager.java:412) 
    at org.apache.hadoop.hbase.client.HConnectionManager.getConnection(HConnectionManager.java:182) 
    at org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:98) 
    at com.bee.searchlib.test.Test.main(Test.java:20) 
Caused by: java.lang.ClassNotFoundException: org.apache.commons.configuration.Configuration 
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247) 
    ... 27 more 

ライブラリ-1.1.1.jar

答えて

5

commons-configuration-x.x.jarをビルドパスに追加します。あなたは$HADOOP_HOME/libの下にそれを見つけることができます。私のために働いた。

1

これはjarファイルのためです。 commons-logging- version.jarそれは私のために働いた

関連する問題