[
https://issues.apache.org/jira/browse/BIGTOP-1012?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13682334#comment-13682334
]
Sean Mackrory commented on BIGTOP-1012:
---------------------------------------
One extra caveat here is that JAVA_HOME is used for more than just the `java`
executable: it's also used to locate libraries like libjvm.so, etc. If `java`
can be found in PATH, that would be better than nothing for most cases, but we
should also try follow symlinks to get to the real JAVA_HOME where the rest of
the JRE can be located.
Also, this should be the last priority in that script. Lots of systems pull in
an unsupported JDK as a dependency for other systems, and that may be found
first in PATH, while a supported JDK should be found through other more
explicit means.
> 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