Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Preconditions

39,859

Solution 1

Make sure you have added the correct Jar to your build path..

Solution 2

Adding guava-11.0.2.jar to the build path solved the issue. This jar is in /share/hadoop/tools/lib folder. I have installed hadoop 2.4.0.

Solution 3

My issue has been resolved by adding the following jar

<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>13.0-rc1</version>
</dependency>

Solution 4

this is caused by Guava-x.y.z.jar because it is missing make sure that you added it

Solution 5

Use google collection JAR from

this might solve your problem.

Share:
39,859

Related videos on Youtube

JGS
Author by

JGS

Updated on December 24, 2020

Comments

  • JGS
    JGS over 3 years

    While running by java map reduce application in eclipse, and facing the below exception. I have included the commons-logging-1.2.jar file in my build path also, but still below is coming.

    I am new to hadoop. Kindly help me out.

    Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Preconditions
        at org.apache.hadoop.conf.Configuration$DeprecationDelta.<init>(Configuration.java:314)
        at org.apache.hadoop.conf.Configuration$DeprecationDelta.<init>(Configuration.java:327)
        at org.apache.hadoop.conf.Configuration.<clinit>(Configuration.java:409)
        at AverageNosClass.main(AverageNosClass.java:71)
    Caused by: java.lang.ClassNotFoundException: com.google.common.base.Preconditions
        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)
        ... 4 more
    
  • JGS
    JGS over 9 years
    I have also added hadoop-common-2.3.0-cdh5.0.0.jar and hadoop-core-2.2.0-mr1-cdh5.0.0.jar. Kidly let me know which other jars i need to add..
  • kd0807
    kd0807 over 9 years
    Have you added Guava libraries? Try adding guava Jar in your build path and test. com.google.common.base.Preconditions is a class in Google Collections Library
  • JGS
    JGS over 9 years
    Thanks..it worked...but again landed in another error. below is the error: Exception in thread "main" java.lang.NoSuchMethodError: org.apache.hadoop.security.authorize.AccessControlList.getAc‌​lString()Ljava/lang/‌​String; Kindly help me...
  • kd0807
    kd0807 over 9 years
    I can see that you have added Hadoop library.. mAy be it is a compatibility issue. Add a newer version of hadoop library, clean your project and see if it works. [link]mvnrepository.com/artifact/org.apache.hadoop/hadoop-co‌​mmon/… Please accept the answer if the problem is solved.
  • JGS
    JGS over 9 years
    After adding all the jars, reducer not working, giving the below error: "java.lang.Exception: java.lang.NoSuchMethodError: com.google.common.collect.Maps.newConcurrentMap()Ljava/util/‌​concurrent/Concurren‌​tMap();" The jar "com.google.guava_1.6.0.jar" already have that method. Kindly Suggest.