java.lang.NoClassDefFoundError: com/google/common when trying to create a Configuration object
I am trying to interact with my HDFS from within java. When I attempt to create a new Configuration object
Configuration conf = new Configuration();
my application throws this error
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Preconditions at org.apache.hadoop.conf.Configuration$DeprecationDelta.<init>(Configuration.java:306) at org.apache.hadoop.conf.Configuration$DeprecationDelta.<init>(Configuration.java:319) at org.apache.hadoop.conf.Configuration.<clinit>(Configuration.java:401)
I have included the hadoop-common-2.0.0-cdh.4.5.0.jar on my java build path and have checked that my hdfs is in fact running hadoop 2.0 cdh 4.5.0.
Am I not including a necessary jar?
Are you using Maven? If not it is advisable to use maven for dependency management.
They have an easy dependency which encapsulates all dependencies:
<dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-client</artifactId> <version>2.0.0-cdh.4.5.0</version> </dependency>
But this particular error is from guava library which you need to include in your classpath. But my guess is you will hit new issues.