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?

Answers


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.


Need Your Help

Make border fade in/out on hover?

jquery html css

Is there an easy way to fade a CSS border-bottom onto my image on hover, and have said border fade out again when not hovered anymore?

In SQL or MySQL, can we join a table and a subquery result?

sql mysql join subquery

Can we join a table with the result of a subquery, such as: