1

I'm trying to get Tomcat to start automatically, and I'm failing miserably. (It's Tomcat 6.0.16 running on Fedora 8, based on Amazon ami-11ca2d78.) So, following standard instructions, I've created /etc/init.d/tomcat containing this:

 export JRE_HOME=/env/jdk1.6.0_07/jre/
 case $1 in
 start)
        sh /env/tomcat/bin/startup.sh
        ;;
 stop)
        sh /env/tomcat/bin/shutdown.sh
        ;;
restart)
        sh /env/tomcat/bin/shutdown.sh
        sh /env/tomcat/bin/startup.sh
         ;;
esac
exit 0

And I chmod 755 it. Then I create soft links:

ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcat
ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat

But when I reboot it fails, and the logs show this exception:

java.lang.IllegalArgumentException: Document base /env/tomcat/webapps/QCServer does not exist or is not a readable directory

But if I run /etc/init.d/tomcat start directly from the command line, everything works fine. And this is a readable directory, with r+x privileges for everyone. So what on earth am I doing wrong? Thanks very much for any help!

AC

2
  • Out of curiosity: Why on earth are you still using Fedora 8? It has seen it's end of life long time ago (see fedoraproject.org/wiki/End_of_life).
    – joschi
    Jun 20, 2010 at 6:05
  • Because that's what Amazon's ami-11ca2d78 is based upon. I want to be able to easily launch my java web app to EC2, preferably from Eclipse, and this is the best ami I've found for the purpose. If you know a better one, please let me know. I'd rather not have to spend endless hours fiddling around configuring such an ami from scratch. I agree, I'd rather use latest releases, but latest releases tend to break other stuff. For example, I need to use Tomcat 6.0.16 on the server, or Eclipse chokes on it. Again, if you know a better alternative I'd love to hear about it. - AC
    – Adrian
    Jun 21, 2010 at 19:11

3 Answers 3

1

If it is readable then the problem is that it can't find the directory. When you started tomcat by hand, you were logged in as 'root' user, I'm guessing. The user has CATALINA_HOME setup to point to where tomcat is installed. I think the problem is tomcat can't find the application base directory.

In server.xml file, where you specified the base directory for 'QCServe', use full path instead of relative path. If you application is installed in /opt/apps/tomcat/webapps/QCServe, then put that absolute path there.

-N

1
  • Alternatively, you can add export CATALINA_HOME=/location/to/tomcat in the /etc/init.d/tomcat file and that should solve the problem. If you have other env variables relating to tomcat, put it in /etc/init.d/tomcat file. Jun 20, 2010 at 6:26
1

What runlevel are you running?

Create the link in /etc/rc3.d

0

Save as /etc/init.d/tomcat, chkconfig add tomcat. Edit the values at the top as needed to tailor to your installation; the values presented are just an example (especially JAVA_OPTS memory settings).

#!/bin/sh
#
# Startup script for Tomcat
#
# chkconfig: 345 82 20
# description: Tomcat is a servlet runner

JAVA_HOME=/usr/local/java
TOMCAT_HOME=/usr/local/tomcat
XMFILE=$TOMCAT_HOME/conf/server.xml
JAVA_OPTS="-server -Xms1536m -Xmx1536m -Xmn384m -XX:+UseParallelGC"
CATALINA_OPTS=""
export JAVA_HOME TOMCAT_HOME JAVA_OPTS CATALINA_OPTS

# See how we were called.
case "$1" in
  start)
    cd $TOMCAT_HOME
    ./bin/startup.sh -config $XMFILE
    ;;
  stop)
    cd $TOMCAT_HOME
    ./bin/shutdown.sh -config $XMFILE
    ;;
  restart)
    $0 stop
    sleep 3
    $0 start
    ;;
  *)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
esac

exit 0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy