Click to See Complete Forum and Search --> : # ./startup.sh Neither the JAVA_HOME nor the JRE_HOME environment variable is defined


sparkles43
03-27-2006, 08:51 PM
When I tried to startup the jakarta-tomcat, it gives me the following response: (the tomcat5 script has been added as a service)

[root@muthasucka ~]# service tomcat5 start
Starting tomcat:
/opt/tomcat5/bin /
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program
/
My environmental path looks like this....

[root@muthasucka ~]# echo $JRE_HOME
/opt/jre1.5.0_06

and I have installed jre in the /opt directory... here is a bit more info

[root@muthasucka opt]# ls -la
total 32
drwxr-xr-x 5 root root 4096 Mar 27 18:05 .
drwxr-xr-x 23 root root 4096 Mar 27 14:38 ..
drwxr-xr-x 12 1000 1000 4096 Mar 14 14:25 httpd-2.2.0
drwxrwxr-x 11 tomcat tomcat 4096 Mar 13 16:23 jakarta-tomcat-5.5.9
drwxr-xr-x 7 root root 4096 Mar 15 14:53 jre1.5.0_06
lrwxrwxrwx 1 root root 25 Mar 15 17:37 tomcat5 -> /opt/jakarta-tomcat-5.5.9

CAN ANYONE TELL ME WHY IT WON'T START EVEN THOUGH I HAVE SPECIFIED THE JRE PATH VARIABLE? IS IT POSSIBLY SOMETHING TO DO WITH MESSAGE SHOWING THE SPACE AFTER BIN?
eg
Starting Tomcat:
/opt/tomcat5/bin /

HELP HELP!!

Choozo
03-28-2006, 01:48 AM
Add JAVA_HOME path early in the startup script.

sparkles43
03-28-2006, 12:34 PM
I have it in there? Is this right or is it something else?

# Source function library.
if [ -x /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi

#
# TODO: I suspect this todo is obvious. Get out the "HOME" vars out of this scr
ipt
# and put them into a proper configuration file.
#
TOMCAT_HOME=/opt/tomcat5
JAVA_HOME=/usr/java/latest
PATH=$JAVA_HOME/bin:$PATH

TOMCAT_START_SCRIPT=startup.sh
TOMCAT_STOP_SCRIPT=shutdown.sh

sparkles43
03-28-2006, 01:04 PM
Then "latest" is a sym link to the java install directory
[root@muthasucka java]# ls -la
total 16
drwxr-xr-x 2 root root 4096 Mar 27 18:06 .
drwxr-xr-x 15 root root 4096 Mar 13 15:25 ..
lrwxrwxrwx 1 root root 16 Mar 27 18:06 latest -> /opt/jre1.5.0_06

Choozo
03-28-2006, 04:57 PM
Try this:

export TOMCAT_HOME=/opt/tomcat5
export JAVA_HOME=/usr/java/latest
export PATH=$JAVA_HOME/bin:$PATH

sparkles43
03-29-2006, 12:40 PM
Should I drop that text in the script itself or simply execute if from the command line?

Choozo
03-29-2006, 04:26 PM
In the script itself. Have a look at the other scripts you have in /etc/init.d/

sparkles43
03-30-2006, 12:09 PM
Well, I tried putting the "export" in front of those lines and it didn't seem to work. I get the same errors. Could it be something with the space after the /opt/tomcat5/bin /? See the space right after that bin directory? Should that not be there? Or is it OK?

[root@muthasucka ~]# service tomcat5 start
Starting tomcat:
/opt/tomcat5/bin /
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program

Choozo
03-30-2006, 03:22 PM
The '/opt/tomcat5/bin /' looks a bit odd, yes.

Please post the complete startup script (enclosed in code tags) so we may have some clue about where that extra space comes into play.

sparkles43
03-30-2006, 09:30 PM
[root@muthasucka init.d]# more tomcat5
#!/bin/bash
#
# Startup script for Tomcat 5.0, the Apache Servlet Engine
#
# chkconfig: 235 80 20
# description: Tomcat Service Script for an installation in /opt/jakarta-tomcat-5.0.28
#
# This simple script is designed to be used to turn a standard /opt installation of
# of tomcat into a service on a linux box. Use chkconfig to install the script as a service.
# It will run the standard tomcat 'startup.sh' script as whatever user you specify upon
# reboot.
#
# You can also use the standard service interface to stop/start tomcat using u_tomcat.
# 'stop' will call the standard 'shutdown.sh' script.
#

# Source function library.
if [ -x /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi

#
# TODO: I suspect this todo is obvious. Get out the "HOME" vars out of this script
# and put them into a proper configuration file.
#
TOMCAT_HOME=/opt/tomcat5
JAVA_HOME=/usr/java/latest
PATH=$JAVA_HOME/bin:$PATH



TOMCAT_START_SCRIPT=startup.sh
TOMCAT_STOP_SCRIPT=shutdown.sh

# Tomcat name :)
TOMCAT_PROG=tomcat

if [ -z "$TOMCAT_USER" ]; then
TOMCAT_USER="tomcat"
fi

RETVAL=0
start() {
echo "Starting $TOMCAT_PROG: "
pushd ${TOMCAT_HOME}/bin
su - $TOMCAT_USER -c "$TOMCAT_HOME/bin/$TOMCAT_START_SCRIPT"
RETVAL=$?
}

stop() {
echo "Stopping $TOMCAT_PROG: "
pushd ${TOMCAT_HOME}/bin
su - $TOMCAT_USER -c "$TOMCAT_HOME/bin/$TOMCAT_STOP_SCRIPT"
RETVAL=$?
popd; sleep 1
}


# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 2
start
;;
*)
echo "Usage: $TOMCAT_PROG {start|stop|restart}"
exit 1
esac

exit $RETVAL

Added CODE tags (Choozo)