I have installed hadoop 2.5.2 and hbase 1.0.1.1 (which are compatible with each other) .But In the hadoop code I am trying to add columnfamily in the hbase table.
My code is
Configuration hbaseConfiguration = HBaseConfiguration.create();
Job hbaseImportJob = new Job(hbaseConfiguration, "FileToHBase");
HBaseAdmin hbaseAdmin = new HBaseAdmin(hbaseConfiguration);
if (!hbaseAdmin.tableExists(Config_values.tableName)) {
TableName tableName1 = TableName.valueOf("tableName");
HTableDescriptor hTableDescriptor = new HTableDescriptor(tableName1);
HColumnDescriptor hColumnDescriptor1 = new HColumnDescriptor("columnFamily1");
hTableDescriptor.addFamily(hColumnDescriptor1);
hbaseAdmin.createTable(hTableDescriptor);
}
I am getting this error
java.lang.NoSuchMethodError: Exception in thread "main" java.lang.NoSuchMethodError: org.apache.hadoop.hbase.HTableDescriptor.addFamily(Lorg/apache/hadoop/hbase/HColumnDescriptor;)V at com.atm_ex.atm_ex.Profiles.profiles(Profiles.java:177) at com.atm_ex.atm_ex.App.main(App.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.hadoop.util.RunJar.main(RunJar.java:212)
I have encountered such an error too! But in a different scenario: I compiled my jar using hbase-0.98, though I run it with hbase-1.0.1.1.
Finally I found that in hbase-0.98, the method signature is
, BUT in hbase-1.0.1.1 it is
There are different!
For safety reason, you should use the same version of hbase for both compiling and running you jar.
The HBase related jar files have to be included in the MapReduce job. Check this Cloudera blog for more details.
For safety reason, you should use the same version of hbase for both compiling and running you jar. when you run mvn clean package -DskipTests=true,make sure that your hbase pom dependence match with your cdh hbase ,not version ,but the same method it contains,the cdh may not follow the apache orign. Maybe you can try use the pom (maven repository) which cdh support on it website.