문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top