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.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
	      // save the put Instance to the HTable.
	      System.out.println("data inserted successfully");
	      // close HTable instance





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 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.lang.reflect.InvocationTargetException
	at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(
	at org.apache.hadoop.hbase.client.ConnectionManager.createConnection(
	at org.apache.hadoop.hbase.client.ConnectionManager.createConnection(
	at org.apache.hadoop.hbase.client.ConnectionManager.getConnectionInternal(
	at org.apache.hadoop.hbase.client.HTable.<init>(
	at org.apache.hadoop.hbase.client.HTable.<init>(
	at _project_267.test.main(
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
	at java.lang.reflect.Constructor.newInstance(
	at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(
	... 6 more
Caused by: java.lang.NoClassDefFoundError: io/netty/channel/EventLoopGroup
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(
	at org.apache.hadoop.conf.Configuration.getClassByNameOrNull(
	at org.apache.hadoop.conf.Configuration.getClassByName(
	at org.apache.hadoop.conf.Configuration.getClass(
	at org.apache.hadoop.conf.Configuration.getClass(
	at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.<init>(
	... 11 more
Caused by: java.lang.ClassNotFoundException:
	at Method)
	at java.lang.ClassLoader.loadClass(
	at sun.misc.Launcher$AppClassLoader.loadClass(
	at java.lang.ClassLoader.loadClass(
	... 18 more