JAVA _Home is not set in Hadoop
I debugged the code and found out that even though JAVA_HOME is set in the environment, the value is lost as ssh connections to other hosts is made inside the code, and the JAVA_HOME variable that was showing well set in start-dfs.sh became unset in hadoop-env.sh.
The solution to this problem will be to set JAVA_HOME variable in hadoop-env.sh and it should work properly.
I had the same error and solved it with Soil Jain's remark, but to make it even a bit more clear: the hadoop-env.sh uses an expression such as
export JAVA_HOME=${JAVA_HOME}
if you hard-code the path to your JVM installation it works
export JAVA_HOME=/usr/lib/jvm/java...
this resolution by environmental variable as is seems to fail. Hard-coding fixed the problem for me.
Under your HADOOP_HOME/conf directory please update the hadoop-env.sh
file. It has entry to export JAVA_HOME.
Setting to appropriate JAVA_HOME in this file should solve your issue.