最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Why am I getting a ClassNotFoundException for hadoop.conf.Configuration in Eclipse? - Stack Overflow

programmeradmin1浏览0评论

I am trying to create a table in Hbase using Java, but I keep getting a ClassNotFoundException.

import .apache.hadoop.hbase.HBaseConfiguration;
import .apache.hadoop.hbase.HColumnDescriptor;
import .apache.hadoop.hbase.HTableDescriptor;
import .apache.hadoop.hbase.TableName;
import .apache.hadoop.hbase.client.*;

import .apache.hadoop.conf.Configuration;
import java.io.IOException;

I've included all of the JAR files from the lib folder of HBase2.6.1-hadoop3 and imported these classes.

public class Upload {

    public static void main(String args[]) throws IOException
    {
        Configuration conf = HBaseConfiguration.create();

When this part of the code runs, I get the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: /slf4j/LoggerFactory
    at .apache.hadoop.conf.Configuration.<clinit>(Configuration.java:230)
    at Upload.main(Upload.java:15)
Caused by: java.lang.ClassNotFoundException: .slf4j.LoggerFactory
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    ... 2 more

Is there any way to fix this?

I am trying to create a table in Hbase using Java, but I keep getting a ClassNotFoundException.

import .apache.hadoop.hbase.HBaseConfiguration;
import .apache.hadoop.hbase.HColumnDescriptor;
import .apache.hadoop.hbase.HTableDescriptor;
import .apache.hadoop.hbase.TableName;
import .apache.hadoop.hbase.client.*;

import .apache.hadoop.conf.Configuration;
import java.io.IOException;

I've included all of the JAR files from the lib folder of HBase2.6.1-hadoop3 and imported these classes.

public class Upload {

    public static void main(String args[]) throws IOException
    {
        Configuration conf = HBaseConfiguration.create();

When this part of the code runs, I get the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: /slf4j/LoggerFactory
    at .apache.hadoop.conf.Configuration.<clinit>(Configuration.java:230)
    at Upload.main(Upload.java:15)
Caused by: java.lang.ClassNotFoundException: .slf4j.LoggerFactory
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    ... 2 more

Is there any way to fix this?

Share Improve this question asked Mar 30 at 0:28 Crimson JesterCrimson Jester 1 5
  • How did you specify your dependencies/used libraries? – dan1st Commented Mar 30 at 0:58
  • I went into the Java Build Path settings, went into libraries, clicked on Classpath, clicked on add External JARS, and added every JAR file in the lib folder of hbase – Crimson Jester Commented Mar 30 at 1:01
  • 1 In that case, I guess hbase/hadoop is dependent on slf4j and might not have it in the lib folder. – dan1st Commented Mar 30 at 1:04
  • Is there any way to find the Configuration class then? – Crimson Jester Commented Mar 30 at 1:12
  • You wrote (in your comment): clicked on Classpath. If you are using a version of Java that uses modules, then you probably need Modulepath. However you are getting NoClassDefFoundError which means your code compiles which means the build path should be correct. Edit your question and post the "run" command. See "Show Command Line" button. – Abra Commented Mar 30 at 4:18
Add a comment  | 

1 Answer 1

Reset to default 0

Check under the external dependencies/libraries in your project in whatever ide you are using, for the slf4j dependency/library and see where its coming under,apart from the actual sl4j dependency ,under the external dependencies/libraries,if it appears in more than one place ,one of the dependencies needs to be removed ,so if you want to use slf4j logging statements ,you can try using the slf4j from the other dependency/library not from original slf4j dependency/library

发布评论

评论列表(0)

  1. 暂无评论