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
Make sure you have added the correct Jar to your build path..
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.
this is caused by Guava-x.y.z.jar because it is missing make sure that you added it
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>
Use google collection JAR from
- http://www.findjar.com/class/com/google/common/base/Preconditions.html
this might solve your problem.
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.
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
I have resolved this issue by adding the guava-14.0.1 library.
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