17

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
Hemang
  • 26,840
  • 19
  • 119
  • 186
JGS
  • 369
  • 2
  • 5
  • 17

9 Answers9

11

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.

6

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

kd0807
  • 660
  • 6
  • 14
  • 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.. – JGS Feb 04 '15 at 09:38
  • 3
    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 – kd0807 Feb 04 '15 at 10:00
  • 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.getAclString()Ljava/lang/String; Kindly help me... – JGS Feb 04 '15 at 13:07
  • 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]http://mvnrepository.com/artifact/org.apache.hadoop/hadoop-common/2.6.0 Please accept the answer if the problem is solved. – kd0807 Feb 05 '15 at 04:58
  • 1
    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/ConcurrentMap();" The jar "com.google.guava_1.6.0.jar" already have that method. Kindly Suggest. – JGS Feb 06 '15 at 09:02
4

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>
Sunil
  • 41
  • 1
3

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

2

Use google collection JAR from

this might solve your problem.

AKs
  • 1,727
  • 14
  • 18
0

Is your Hadoop lib directory contains all the jar files which you used in your eclipse project ?

If not place them in Hadoop lib directory and restart hadoop.

sras
  • 818
  • 7
  • 18
0

I have had this error too when trying to use MRUnit and the maven dependency was not found, so I tried to add it manually. Is this your case?

The problem is that if you add the jar manually, it will keep failing asking for the rest of MRUnit jars (the ones in the pom of MRUnit) until you add them all with the same version as in its pom.

The cause of mrunit not being found was that I was not using the necessary classifier in the dependecy declaration

The solution is adding the classifier hadoop1 or hadoop2

Edu Castrillon
  • 527
  • 1
  • 12
  • 28
0

I have resolved this issue by adding the guava-14.0.1 library.

Sanjeet Pandey
  • 546
  • 4
  • 23
0

We had a similar issue, hoping this will help someone: We had the jar in our classpath, but still this issue occurred. The reason was - inside build.gradle it was being loaded as compileOnly. Changing it to implementation made it work

JavaTec
  • 965
  • 3
  • 15
  • 30