1833315 Members
2998 Online
110051 Solutions
New Discussion

start script problem

 
Norman Dignard
Regular Advisor

start script problem

Can someone tell me why my start script is not starting tomcat on bootup? It starts fine by root or init3 calling the script but not on a full system bootup. I downgraded tomcat 5.5 to 5.0.28 due to compatibility problems with our app. This is on a HPUX 11.31 IA64 system.

Below are the contents and file settings:
root@nesaweb/homeroot #ps -ef |grep tomcat
root@nesaweb/homeroot #ps -ef |grep java
root 3458 3049 1 14:36:40 ttyp1 0:00 grep java



ll /etc/rc.config.d/tomcat
-r--r--r-- 1 bin bin 519 Jul 3 14:05 tomcat

In /etc/rc.config.d/tomcat
# Tomcat Servlet Container configuration file

# Set TOMCAT_START to 1 to have the Tomcat servlet-container started
# by the init process.
TOMCAT_START=1

# Set TOMCAT_HOME to the location of the Tomcat servlet-container.
# Default is /opt/hpws/tomcat
TOMCAT_HOME=/opt/jakarta-tomcat-5.0.28

# Set JAVA_HOME to the location of the java installation.
# It is required by Tomcat.
# Default is /opt/java1.5
# Set it to /opt/java1.4 when using the compatibility package to run Tomcat
# with JDK 1.4
JAVA_HOME=/opt/java1.4

ll /sbin/init.d/tomcat
-r-xr-xr-x 1 bin bin 2642 Jul 3 14:08 tomcat

ll ../rc2.d/K180tomcat
lrwxrwxrwx 1 root sys 19 Jun 13 11:42 ../rc2.d/K180tomcat -> /sbin/init.d/tomcat


ll ../rc3.d/S890tomcat
lrwxrwxrwx 1 root sys 19 Jun 13 11:43 S890tomcat -> /sbin/init.d/tomcat

In /sbin/init.d/tomcat
#!/sbin/sh
# set -x
#
# @(#) $Revision: 82.1 $
#
# NOTE: This script is not configurable! Any changes made to this
# script will be overwritten when you upgrade to the next
# release of HP-UX.
#
# WARNING: Changing this script in any way may lead to a system that
# is unbootable. Do not modify this script.

#
# The Tomcat script is for used for starting up the Tomcat servlet
# container by default at boot-up time.
# Configurable options are:
# JAVA_HOME
# TOMCAT_HOME
# TOMCAT_START
# These options can be supplied in /etc/rc.config.d/tomcat file.
#

# Allowed exit values:
# 0 = success; causes "OK" to show up in checklist.
# 1 = failure; causes "FAIL" to show up in checklist.
# 2 = skip; causes "N/A" to show up in the checklist.
# Use this value if execution of this script is overridden
# by the use of a control variable, or if this script is not
# appropriate to execute for some other reason.
# 3 = reboot; causes the system to be rebooted after execution.
# 4 = background; causes "BG" to show up in the checklist.
# Use this value if this script starts a process in background mode.

# Input and output:
# stdin is redirected from /dev/null
#
# stdout and stderr are redirected to the /etc/rc.log file
# during checklist mode, or to the console in raw mode.

export PATH=/usr/sbin:/usr/bin:/sbin

# Assume "excluded"
rval=2

# source the system configuration variables
if [ -f /etc/rc.config.d/tomcat ] ; then
. /etc/rc.config.d/tomcat
else
echo "ERROR: /etc/rc.config.d/tomcat defaults file MISSING"
fi

export JAVA_HOME TOMCAT_HOME

# run Tomcat with nohup
export JAVA_WRAPPER=nohup

case $1 in
'start_msg')
echo "Starting Tomcat-based Servlet Engine"
;;

'stop_msg')
echo "Stopping Tomcat-based Servlet Engine."
;;

'start')
# Check to see if Tomcat needs to be run...
if [ $TOMCAT_START -ne 1 ]; then
if [ $rval -ne 0 ]; then
rval=2
fi
else
# Execute the commands to start your subsystem
$TOMCAT_HOME/bin/startup.sh 1>/dev/null 2>&1

if [ $? -ne 0 ]; then
echo "ERROR: Could not start Tomcat."
else
rval=0
echo "Tomcat Started."
fi
fi
;;

'stop')
# Check to see if Tomcat needs to be shutdown...
if [ $TOMCAT_START -ne 1 ]; then
if [ $rval -ne 0 ]; then
rval=2
fi
else
# Execute the commands to stop Tomcat
$TOMCAT_HOME/bin/shutdown.sh 1>/dev/null 2>&1
rval=0
fi
;;

*)
echo "usage: $0 {start|stop|start_msg|stop_msg}"
rval=1
;;
esac

exit $rval
16 REPLIES 16
Ninad_1
Honored Contributor

Re: start script problem

Have you checked the /etc/rc.log file for any errors during startup/system bootup ?

Regards,
Ninad
Norman Dignard
Regular Advisor

Re: start script problem

Yes I checked the rc.log file and all it states is "tomcat started".
OldSchool
Honored Contributor

Re: start script problem

what is the contents of $TOMCAT_HOME/bin/startup.sh?
Norman Dignard
Regular Advisor

Re: start script problem

Haven't changed the tomcat startup.sh script
-rwxr-xr-x 1 root root 971 Jun 21 11:55 startup.sh

startup.sh has the following:
#!/bin/sh
# -----------------------------------------------------------------------------
# Start Script for the CATALINA Server
#
# $Id: startup.sh,v 1.3 2002/08/04 18:19:43 patrickl Exp $
# -----------------------------------------------------------------------------

# resolve links - $0 may be a softlink
PRG="$0"

while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '.*/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`/"$link"
fi
done

PRGDIR=`dirname "$PRG"`
EXECUTABLE=catalina.sh
DISPLAY=:0; export DISPLAY
JAVA_HOME=/opt/java1.4; export JAVA_HOME
CATALINA_HOME=/opt/jakarta-tomcat-5.0.28;export CATALINA_HOME
SHLIB_PATH=/opt/arweb/WEB-INF/lib; export SHLIB_PATH

# Check that target executable exists
if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
echo "Cannot find $PRGDIR/$EXECUTABLE"
echo "This file is needed to run this program"
exit 1
fi

exec "$PRGDIR"/"$EXECUTABLE" start "$@"
Geoff Wild
Honored Contributor

Re: start script problem

My Tomcat looks like this:

root@sha1 [ /sbin/init.d ]
# cat hpws_tomcat
#!/sbin/sh
#
# @(#) $Revision: 82.1 $
#
# NOTE: This script is not configurable! Any changes made to this
# script will be overwritten when you upgrade to the next
# release of HP-UX.
#
# WARNING: Changing this script in any way may lead to a system that
# is unbootable. Do not modify this script.

#
# The Tomcat script is for used for starting up the Tomcat servlet
# container by default at boot-up time.
# Configurable options are:
# JAVA_HOME
# HPWS_TOMCAT_HOME
# HPWS_TOMCAT_START
# These options can be supplied in /etc/rc.config.d/hpws_tomcatconf file.
#

# Allowed exit values:
# 0 = success; causes "OK" to show up in checklist.
# 1 = failure; causes "FAIL" to show up in checklist.
# 2 = skip; causes "N/A" to show up in the checklist.
# Use this value if execution of this script is overridden
# by the use of a control variable, or if this script is not
# appropriate to execute for some other reason.
# 3 = reboot; causes the system to be rebooted after execution.
# 4 = background; causes "BG" to show up in the checklist.
# Use this value if this script starts a process in background mode.

# Input and output:
# stdin is redirected from /dev/null
#
# stdout and stderr are redirected to the /etc/rc.log file
# during checklist mode, or to the console in raw mode.

export PATH=/usr/sbin:/usr/bin:/sbin

# Assume "excluded"
rval=2

# source the system configuration variables
if [ -f /etc/rc.config ] ; then
. /etc/rc.config
else
echo "ERROR: /etc/rc.config defaults file MISSING"
fi

export JAVA_HOME HPWS_TOMCAT_HOME

# run Tomcat with nohup
export JAVA_WRAPPER=nohup

case $1 in
'start_msg')
echo "Starting HP-UX Tomcat-based Servlet Engine"
;;

'stop_msg')
echo "Stopping HP-UX Tomcat-based Servlet Engine."
;;

'start')
# Check to see if Tomcat needs to be run...
if [ $HPWS_TOMCAT_START -ne 1 ]; then
if [ $rval -ne 0 ]; then
rval=2
fi
else
# Execute the commands to start your subsystem
$HPWS_TOMCAT_HOME/bin/startup.sh 1>/dev/null 2>&1

if [ $? -ne 0 ]; then
echo "ERROR: Could not start Tomcat."
else
rval=0
echo "Tomcat Started."
fi
fi
;;

'stop')
# Check to see if Tomcat needs to be shutdown...
if [ $HPWS_TOMCAT_START -ne 1 ]; then
if [ $rval -ne 0 ]; then
rval=2
fi
else
# Execute the commands to stop Tomcat
$HPWS_TOMCAT_HOME/bin/shutdown.sh 1>/dev/null 2>&1
rval=0
fi
;;

*)
echo "usage: $0 {start|stop|start_msg|stop_msg}"
rval=1
;;
esac

exit $rval

# ll /sbin/*/*tom*
-r-xr-xr-x 1 bin bin 2609 Oct 7 2005 /sbin/init.d/hpws_tomcat
lrwxr-xr-x 1 bin bin 24 Apr 18 10:25 /sbin/rc2.d/K177hpws_tomcat -> /sbin/init.d/hpws_tomcat
lrwxr-xr-x 1 bin bin 24 Apr 18 10:25 /sbin/rc3.d/S823hpws_tomcat -> /sbin/init.d/hpws_tomcat



Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Ralph Grothe
Honored Contributor

Re: start script problem

Hi Norman,

I don't know if the excerpt of the init script you provided is complete, nor whether I have missed something.
But what boggles me is that you first have this assignment

# Assume "excluded"
rval=2

and then a little further down, without rval being reassigned, in the start) match of the case block you have this conditional

if [ $rval -ne 0 ]; then
rval=2
fi
else
# Execute the commands to start your subsystem
$TOMCAT_HOME/bin/startup.sh 1>/dev/null 2>&1


Could look like you have a premature exit here.
Madness, thy name is system administration
Norman Dignard
Regular Advisor

Re: start script problem

As for the init script, all I did was take HP's init script from their default install of tomcat and striped out the HP and HPWS_ references. 0ther then that its as out-of-the-box as it gets.

I also tried using a basic script as seen below which also starts tomcat fine as root or doing an init 3 but again it does not start on bootup. I went back to using HP's tomcat init script to try and figure it out.

#!/sbin/sh

case $1 in
'start_msg')
echo "Starting Tomcat-based Servlet Engine"
;;

'stop_msg')
echo "Stopping Tomcat-based Servlet Engine"
;;

'start')
# Execute the commands to start your subsystem
if [ -f /opt/jakarta-tomcat-5.0.28/bin/startup.sh ]; then
/usr/bin/su - root -c "/opt/jakarta-tomcat-5.0.28/bin/startup.sh" 1>/dev/null 2>&1
else
echo "Tomcat Start script not found"
fi
;;

'stop')
# Execute the commands to stop Tomcat

if [ -f /opt/jakarta-tomcat-5.0.28/bin/shutdown.sh ]; then
/usr/bin/su - root -c "/opt/jakarta-tomcat-5.0.28/bin/shutdown.sh 1>/dev/null 2>&1"
else
echo "Tomcat Stop script not found"
fi
;;

*)
echo "usage: 'basename $0 {start|stop}"
;;

esac
Geoff Wild
Honored Contributor

Re: start script problem

Change:

if [ -f /etc/rc.config.d/tomcat ] ; then
. /etc/rc.config.d/tomcat
else
echo "ERROR: /etc/rc.config.d/tomcat defaults file MISSING"
fi


To:

if [ -f /etc/rc.config ] ; then
. /etc/rc.config
else
echo "ERROR: /etc/rc.config defaults file MISSING"
fi



Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Norman Dignard
Regular Advisor

Re: start script problem

Changing /etc/rc.config.d/tomcat to /etc/rc.config did not make a difference.
Tomcat still does not start on bootup as java process created by tomcat is not there.
Peter Nikitka
Honored Contributor

Re: start script problem

Hi,

I recommend to send the output of the start commands not to /dev/null but to logfiles, like
...
$TOMCAT_HOME/bin/startup.sh >/tmp/tomcat.startout 2>/tmp/tomcat.starterr
...

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Geoff Wild
Honored Contributor

Re: start script problem

I agree with Peter - try to get some more log info.

This is starting to sound like tomcat needs something else running prior to starting - hence it works fine after you login and start manuall....maybe make it the last thing that starts?

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Norman Dignard
Regular Advisor

Re: start script problem

tomcat is the last thing to start before CDE.
As for redirecting stnd err & out, DId that and nothing reported in the log files.
Geoff Wild
Honored Contributor

Re: start script problem

Okay - this is starting to tick me off....time to get down and dirty...

Let us start checking logic in the script...

Cahnge

$TOMCAT_HOME/bin/startup.sh 1>/dev/null 2>&1

To

$TOMCAT_HOME/bin/nosuchfile.sh 1>/dev/null 2>&1


Does it FAIL now on startup?

If it does, then the logic is ok and the issue maybe the actual startup.sh script - if it doesn't then the logic in the /sbin/init.d script is messed up somewhere.


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Peter Nikitka
Honored Contributor

Re: start script problem

Hi,

you can also try it the other way round:
Call the startscript at the shell level and look for the logfile after this.
If they contain something, your startup anchor may not be correct.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Norman Dignard
Regular Advisor

Re: start script problem

Hi Guru's - Someones tick'd. Well join the crowd. I've been trying to solve this for 2 weeks.

I changed the tomcat init script to point to a no-exixtant file and tomcat startup fails with the msg "can't find file".

I added
in /sbin/init.d/tomcat
set -x > /tmp/tom.log 2>&1
and in start section:
$TOMCAT_HOME/bin/startup.sh 1>/tmp/tom.out 2>/tmp/tom.err
(nothing gets reported in tom.out and tom.err has the same on bootup to cmd line start. See below)

in /opt/jakata-tomcat-5.0.28.bin/startup.sh
set -x > /tmp/tomstart.log 2>&1
exec "$PRGDIR"/"$EXECUTABLE" start "$@" 1>/tmp/tomstart1.log 2>&1

(tomstart1 has the same on bootup to cmd line start. See below)

in /opt/jakata-tomcat-5.0.28.bin/catalina.sh
set -x > /tmp/catstart.log 2>&1

and in run section
org.apache.catalina.startup.Bootstrap "$@" start 1>/tmp/catrun.log 2>&1

(nothbing logged both catrun and catstart in both cmdline and bootup start)


Running >tomcat start gives to the console

+ export PATH=/usr/sbin:/usr/bin:/sbin
+ rval=2
+ [ -f /etc/rc.config.d/tomcat ]
+ . /etc/rc.config.d/tomcat
+ TOMCAT_START=1
+ TOMCAT_HOME=/opt/jakarta-tomcat-5.0.28
+ JAVA_HOME=/opt/java1.4
+ export JAVA_HOME TOMCAT_HOME
+ export JAVA_WRAPPER=nohup
+ [ 1 -ne 1 ]
+ /opt/jakarta-tomcat-5.0.28/bin/startup.sh
+ 1> /tmp/tom.out 2> /tmp/tom.err
+ [ 0 -ne 0 ]
+ rval=0
+ echo Tomcat Started.
Tomcat Started.
+ exit 0


# tom.err logs:
+ PRG=/opt/jakarta-tomcat-5.0.28/bin/startup.sh
+ [ -h /opt/jakarta-tomcat-5.0.28/bin/startup.sh ]
+ + dirname /opt/jakarta-tomcat-5.0.28/bin/startup.sh
PRGDIR=/opt/jakarta-tomcat-5.0.28/bin
+ EXECUTABLE=catalina.sh
+ DISPLAY=:0
+ export DISPLAY
+ JAVA_HOME=/opt/java1.4
+ export JAVA_HOME
+ CATALINA_HOME=/opt/jakarta-tomcat-5.0.28
+ export CATALINA_HOME
+ SHLIB_PATH=/opt/arweb/WEB-INF/lib
+ export SHLIB_PATH
+ [ ! -x /opt/jakarta-tomcat-5.0.28/bin/catalina.sh ]
+ exec /opt/jakarta-tomcat-5.0.28/bin/catalina.sh start
+ 1> /tmp/tomstart1.log 2>& 1


# tomstart1.log logs:
+ cygwin=false
+ os400=false
+ uname
+ PRG=/opt/jakarta-tomcat-5.0.28/bin/catalina.sh
+ [ -h /opt/jakarta-tomcat-5.0.28/bin/catalina.sh ]
+ + dirname /opt/jakarta-tomcat-5.0.28/bin/catalina.sh
PRGDIR=/opt/jakarta-tomcat-5.0.28/bin
+ [ -z /opt/jakarta-tomcat-5.0.28 ]
+ [ -r /opt/jakarta-tomcat-5.0.28/bin/setenv.sh ]
+ false
+ false
+ [ -r /opt/jakarta-tomcat-5.0.28/bin/setclasspath.sh ]
+ BASEDIR=/opt/jakarta-tomcat-5.0.28
+ . /opt/jakarta-tomcat-5.0.28/bin/setclasspath.sh
+ [ -z /opt/java1.4 ]
+ false
+ [ ! -x /opt/java1.4/bin/java -o ! -x /opt/java1.4/bin/jdb -o ! -x /opt/java1.4/bin/javac ]
+ [ -z /opt/jakarta-tomcat-5.0.28 ]
+ [ ! -x /opt/jakarta-tomcat-5.0.28/bin/setclasspath.sh ]
+ JAVA_ENDORSED_DIRS=/opt/jakarta-tomcat-5.0.28/common/endorsed
+ CLASSPATH=/opt/java1.4/lib/tools.jar
+ JIKESPATH=
+ uname -s
+ [ HP-UX = Darwin ]
+ _RUNJAVA=/opt/java1.4/bin/java
+ [ false = false ]
+ _RUNJDB=/opt/java1.4/bin/jdb
+ _RUNJAVAC=/opt/java1.4/bin/javac
+ [ -n ]
+ CLASSPATH=/opt/java1.4/lib/tools.jar:/opt/jakarta-tomcat-5.0.28/bin/bootstrap.jar:/opt/jakarta-tom
cat-5.0.28/bin/commons-logging-api.jar
+ [ -z ]
+ CATALINA_BASE=/opt/jakarta-tomcat-5.0.28
+ [ -z ]
+ CATALINA_TMPDIR=/opt/jakarta-tomcat-5.0.28/temp
+ false
+ echo Using CATALINA_BASE: /opt/jakarta-tomcat-5.0.28
Using CATALINA_BASE: /opt/jakarta-tomcat-5.0.28
+ echo Using CATALINA_HOME: /opt/jakarta-tomcat-5.0.28
Using CATALINA_HOME: /opt/jakarta-tomcat-5.0.28
+ echo Using CATALINA_TMPDIR: /opt/jakarta-tomcat-5.0.28/temp
Using CATALINA_TMPDIR: /opt/jakarta-tomcat-5.0.28/temp
+ echo Using JAVA_HOME: /opt/java1.4
Using JAVA_HOME: /opt/java1.4
+ [ start = jpda ]
+ [ start = debug ]
+ [ start = run ]
+ [ start = start ]
+ shift
+ touch /opt/jakarta-tomcat-5.0.28/logs/catalina.out
+ [ = -security ]
+ [ ! -z ]
+ /opt/java1.4/bin/java -Djava.endorsed.dirs=/opt/jakarta-tomcat-5.0.28/common/endorsed -classpath /
opt/java1.4/lib/tools.jar:/opt/jakarta-tomcat-5.0.28/bin/bootstrap.jar:/opt/jakarta-tomcat-5.0.28/bi
n/commons-logging-api.jar -Dcatalina.base=/opt/jakarta-tomcat-5.0.28 -Dcatalina.home=/opt/jakarta-to
mcat-5.0.28 -Djava.io.tmpdir=/opt/jakarta-tomcat-5.0.28/temp org.apache.catalina.startup.Bootstrap s
tart
+ 1>> /opt/jakarta-tomcat-5.0.28/logs/catalina.out 2>& 1

# Nothing recorded in catalina.log on bootup
# On cmd line startup catalina.out records:
Jul 6, 2007 9:24:59 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Jul 6, 2007 9:25:00 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 6225 ms
Jul 6, 2007 9:25:00 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Jul 6, 2007 9:25:00 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.0.28
Jul 6, 2007 9:25:01 AM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Jul 6, 2007 9:25:01 AM org.apache.catalina.core.StandardHost getDeployer
INFO: Create Host deployer for direct deployment ( non-jmx )
Jul 6, 2007 9:25:01 AM org.apache.catalina.core.StandardHostDeployer install
INFO: Processing Context configuration file URL file:/opt/jakarta-tomcat-5.0.28/
conf/Catalina/localhost/admin.xml
Jul 6, 2007 9:25:06 AM org.apache.struts.util.PropertyMessageResources
INFO: Initializing, config='org.apache.struts.util.LocalStrings', returnNull=tru
e
Jul 6, 2007 9:25:06 AM org.apache.struts.util.PropertyMessageResources
INFO: Initializing, config='org.apache.struts.action.ActionResources', returnNul
l=true

# Also tomcat's localhostxxx.txt log records the following but nothing on a reboot.

2007-07-06 09:25:14 StandardContext[/balancer]org.apache.webapp.balancer.Balance
rFilter: init(): ruleChain: [org.apache.webapp.balancer.RuleChain: [org.apache.w
ebapp.balancer.rules.URLStringMatchRule: Target string: News / Redirect URL: htt
p://www.cnn.com], [org.apache.webapp.balancer.rules.RequestParameterRule: Target
param name: paramName / Target param value: paramValue / Redirect URL: http://w
ww.yahoo.com], [org.apache.webapp.balancer.rules.AcceptEverythingRule: Redirect
URL: http://jakarta.apache.org]]
2007-07-06 09:25:24 StandardContext[/jsp-examples]ContextListener: contextInitia
lized()
2007-07-06 09:25:24 StandardContext[/jsp-examples]SessionListener: contextInitia
lized()
2007-07-06 09:25:25 StandardContext[/servlets-examples]ContextListener: contextI
nitialized()
2007-07-06 09:25:25 StandardContext[/servlets-examples]SessionListener: contextI
nitialized()
Gaston Martin
New Member

Re: start script problem

I'm facing the same problem...

One thing you can try is to set the logging properties to ALL, in order to see all messages in the Log.