You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@bigtop.apache.org by "Rick Schultz (JIRA)" <ji...@apache.org> on 2013/06/13 01:08:20 UTC

[jira] [Created] (BIGTOP-1012) bigtop-detect-javahome should check PATH if JAVA_HOME is unset

Rick Schultz created BIGTOP-1012:
------------------------------------

             Summary: bigtop-detect-javahome should check PATH if JAVA_HOME is unset
                 Key: BIGTOP-1012
                 URL: https://issues.apache.org/jira/browse/BIGTOP-1012
             Project: Bigtop
          Issue Type: Bug
            Reporter: Rick Schultz


Even in cases where java is in a user's $PATH, bigtop-detect-javahome will only check a fixed list of locations and leave JAVA_HOME unset if java is installed somewhere else.  Folks who install a non-distro JRE/JDK are likely to put it into /usr/local or /opt and modify PATH appropriately.

Other projects (cf. FLUME-1154) are working around this in their own init scripts.  This should be handled centrally within the bigtop-detect-javahome script itself.

{code}
diff --git a/bigtop-packages/src/common/bigtop-utils/bigtop-detect-javahome b/bigtop-packages/src/common/bigtop-utils/bigtop-detect-javahome
index de64e1d..b3b858a 100644
--- a/bigtop-packages/src/common/bigtop-utils/bigtop-detect-javahome
+++ b/bigtop-packages/src/common/bigtop-utils/bigtop-detect-javahome
@@ -52,3 +52,9 @@ if [ -z "$JAVA_HOME" ]; then
   done
 fi
 
+if [ -z "${JAVA_HOME}" ] ; then
+  JAVA_DEFAULT=$(type -p java)
+  if [ -n "$JAVA_DEFAULT" ] ; then 
+    export JAVA_HOME=$(cd $(dirname $(readlink -f $JAVA_DEFAULT))/..; pwd)
+  fi
+fi
{code}

This can be reproduced installing Cloudera [CDH4|http://www.cloudera.com/content/cloudera-content/cloudera-docs/CDH4/latest/CDH4-Installation-Guide/cdh4ig_topic_4_4.html] on a host where java is in /usr/local/bin:

{code}
ubuntu:~$ type -a java
java is /usr/local/bin/java
ubuntu:~$ sudo vi /etc/apt/sources.list.d/cloudera.list
ubuntu:~$ curl -s http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh/archive.key| sudo apt-key add -
OK
ubuntu:~$ sudo apt-get update
(...)
ubuntu:~$ sudo apt-get install hadoop-0.20-mapreduce-jobtracker
Reading package lists... Done
(...)
Setting up hadoop-hdfs (2.0.0+1357-1.cdh4.3.0.p0.21~precise-cdh4.3.0) ...
Setting up hadoop-0.20-mapreduce (2.0.0+1357-1.cdh4.3.0.p0.21~precise-cdh4.3.0) ...
Setting up hadoop-0.20-mapreduce-jobtracker (2.0.0+1357-1.cdh4.3.0.p0.21~precise-cdh4.3.0) ...
 * Starting Hadoop jobtracker: 
+======================================================================+
|      Error: JAVA_HOME is not set and Java could not be found         |
+----------------------------------------------------------------------+
| Please download the latest Sun JDK from the Sun Java web site        |
|       > http://java.sun.com/javase/downloads/ <                      |
|                                                                      |
| Hadoop requires Java 1.6 or later.                                   |
| NOTE: This script will find Sun Java whether you install using the   |
|       binary or the RPM based installer.                             |
+======================================================================+
invoke-rc.d: initscript hadoop-0.20-mapreduce-jobtracker, action "start" failed.
{code}


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira