Support Questions
Find answers, ask questions, and share your expertise

Unable to use HBase API in Cloudera Quickstart VM [Eclipse]

Unable to use HBase API in Cloudera Quickstart VM [Eclipse]

New Contributor

I've spent a considerable amount of time on the internet trying to find a fix but have had no luck whatsoever so any help would be greatly appreciated.

 

Basically I'm trying to perform simple tasks with the HBase API in the Cloudera Quickstart VM's Eclipse editor. I'm able to access HBase through the shell without issue, but whenever I try to run a Java program in Eclipse that utilizes the HBase API I'll receive numerous errors with ClassNotFound exceptions. Below is an example of a simple Java program that writes some data to a an existing HBase table, and further below that are some errors that popped up.

 

I'm included literally all of the /usr/lib/hbase jar files into the project buildpath and I get no visible errors, it's only when I run the program the errrors show up.

 

Java code below

 

 

 

package _project_267;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.text.ParseException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.util.Bytes;


public class test {

	public static void main(String[] args) throws UnsupportedEncodingException, IOException, ParseException {
		// TODO Auto-generated method stub
		
		Configuration config = HBaseConfiguration.create();
		HTable hTable = new HTable(config, "person");

	      // instantiate Put class
	      Put p = new Put(Bytes.toBytes("test")); 

	      // add values using add() method
	      p.add(Bytes.toBytes("personal"),
			Bytes.toBytes("name"),Bytes.toBytes("Vivek"));
	      p.add(Bytes.toBytes("personal"),
			Bytes.toBytes("age"),Bytes.toBytes("17"));
	      
	      // save the put Instance to the HTable.
	      hTable.put(p);
	      System.out.println("data inserted successfully");
	      
	      // close HTable instance
	      hTable.close();     
	}
}

 

 

 

 

Runtime errors below

 

 

 

20/05/12 18:52:43 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
20/05/12 18:52:44 INFO zookeeper.RecoverableZooKeeper: Process identifier=hconnection-0x4553dc23 connecting to ZooKeeper ensemble=localhost:2181
Exception in thread "main" java.io.IOException: java.lang.reflect.InvocationTargetException
	at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:240)
	at org.apache.hadoop.hbase.client.ConnectionManager.createConnection(ConnectionManager.java:433)
	at org.apache.hadoop.hbase.client.ConnectionManager.createConnection(ConnectionManager.java:426)
	at org.apache.hadoop.hbase.client.ConnectionManager.getConnectionInternal(ConnectionManager.java:304)
	at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:186)
	at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:152)
	at _project_267.test.main(test.java:21)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:238)
	... 6 more
Caused by: java.lang.NoClassDefFoundError: io/netty/channel/EventLoopGroup
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:270)
	at org.apache.hadoop.conf.Configuration.getClassByNameOrNull(Configuration.java:2288)
	at org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:2253)
	at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:2347)
	at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:2373)
	at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.<init>(ConnectionManager.java:667)
	... 11 more
Caused by: java.lang.ClassNotFoundException: io.netty.channel.EventLoopGroup
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	... 18 more