Hadoop: The Definitive Guide (3rd Ed) error with MaxTemperature example

In the book Hadoop: The Definitive Guide (3rd Ed), there is an error in Chapter 2 MapReduce (the error is also in the ePub and PDF versions).  The book shows setting HADOOP_CLASSPATH=hadoop-examples.jar, however this JAR file does not exist.  The Ant build.xml creates a job.jar file which contains all of the examples included in the book.  Setting HADOOP_CLASSPATH=job.jar fixes this problem and allows the example to work properly.

The error you will get if you have the HADOOP_CLASSPATH set incorrectly (as specified in the book) will be:

[root@hadoop01 hadoop-book]# hadoop MaxTemperature input/ncdc/sample.txt output
Exception in thread “main” java.lang.NoClassDefFoundError: MaxTemperature
Caused by: java.lang.ClassNotFoundException: MaxTemperature
        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)
Could not find the main class: MaxTemperature. Program will exit.
I have submitted this correction to be included in the Errata and hopefully it will be reflected on the books website soon.
This entry was posted in Data Analytics. Bookmark the permalink.

Leave a Reply