Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Flume, mail # dev - Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Maps


Copy link to this message
-
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Maps
kashif khan 2012-11-20, 14:22
Dear all,

I am running simple java program to create a directory in HDFS. The code as:
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import java.io.IOException;

public class CopyFile {

        public static void main(String[] args) throws IOException{
        Configuration conf = new Configuration();
        //conf.set("fs.default.name", "hadoop1.brunel.ac.uk:8020");
        conf.addResource(new Path("/etc/hadoop/conf/core-site.xml"));
        conf.addResource(new Path ("/etc/hadoop/conf/hdfs-site.xml"));
        FileSystem dfs = FileSystem.get(conf);
        String dirName = "Test1";
        Path src = new Path(dfs.getWorkingDirectory() + "/" + dirName);
        dfs.mkdirs(src);
        //Path scr1 = new Path("/usr/Eclipse/Output.csv");
        //Path dst = new Path(dfs.getWorkingDirectory() + "/Test1/");
        //dfs.copyFromLocalFile(scr1, dst);
        System.out.println("Directory created:" + src);
        }
        }
Generating the following error message. Anyone have any idea about this
error. Please let me know.
Exception in thread "main" java.lang.NoClassDefFoundError:
com/google/common/collect/Maps
    at
org.apache.hadoop.metrics2.lib.MetricsRegistry.<init>(MetricsRegistry.java:42)
    at
org.apache.hadoop.metrics2.impl.MetricsSystemImpl.<init>(MetricsSystemImpl.java:87)
    at
org.apache.hadoop.metrics2.impl.MetricsSystemImpl.<init>(MetricsSystemImpl.java:133)
    at
org.apache.hadoop.metrics2.lib.DefaultMetricsSystem.<init>(DefaultMetricsSystem.java:38)
    at
org.apache.hadoop.metrics2.lib.DefaultMetricsSystem.<clinit>(DefaultMetricsSystem.java:36)
    at
org.apache.hadoop.security.UserGroupInformation$UgiMetrics.create(UserGroupInformation.java:97)
    at
org.apache.hadoop.security.UserGroupInformation.<clinit>(UserGroupInformation.java:190)
    at
org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:2373)
    at
org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:2365)
    at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2233)
    at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:300)
    at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:156)
    at CopyFile.main(CopyFile.java:14)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Maps
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    ... 13 more

Please let me know, if anyone have any idea about the error.

Many thanks

Best regards,

KK