I'm learning how to write a map / reduce job in hadoop with mongodb data as input. So I followed this example, but I got following error :
Exception in thread "main" java.lang.NoClassDefFoundError: com/mongodb/hadoop/util/MongoConfigUtil
at WordCount.main(WordCount.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Caused by: java.lang.ClassNotFoundException: com.mongodb.hadoop.util.MongoConfigUtil
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
I've been searching for hours without any result. Any one can help me please.
it means
mongo-hadoop-core.jaris available at compile time but not at run time.Try running your application with dependency jars added in classpath
Example :
java -cp mongo-hadoop-core.jar<++other dependencies> MainClassEDIT 1
If you're running using
hadoopshellcheck the
classpathby executinghadoop classpathit will print the dir/jars in the classpath.If the dependent jars are not in the classpath add them in the
classpathusingexportcommand then executehadoop jar yourjar.jar mainClassEDIT 2
make use of
libjarsoptionhadoop jar myjar.jar mainClass -libjars ${LIBJARS}