user2233398
user2233398

Reputation: 1

NoSuchMethodError() when upgrading to hbase-0.94.2

I am getting this error in my source code:

java.lang.NoSuchMethodError: org.apache.hadoop.hbase.HColumnDescriptor.setMaxVersions(I)V

when I upgraded from hbase-0.92.1-cdh4.1.1 to hbase-0.94.2-cdh4.2.0 I see that the signature of the method is changed from

public void setMaxVersions(int maxVersions)

to

public HColumnDescriptor setMaxVersions(int maxVersions)

I am guessing there is binary compatibility is lost. Could someone shed some light on how this can be resolved? Thanks.

Upvotes: 0

Views: 200

Answers (1)

user3182427
user3182427

Reputation: 11

You can use Java Reflection to do this:

HColumnDescriptor fam1 = new HColumnDescriptor(Bytes.toBytes('cf'));
Method method = fam1.getClass().getMethod("setMaxVersions", Integer.TYPE);
method.invoke(fam1, 10);

Upvotes: 1

Related Questions