Tomcat 5.5 not starting on boot

Hello I am sort of new to VPS hosting and have a little Linux experience. I just got a Linode 450 and set it up running Suse 10.3 with MySQL5, Tomcat 5.5, webmin, and the Susefirewall. (I opened port 8080 on the firewall so that is not the problem)

The problem I am having is I cannot seem to get Tomcat to start automatically when the linode is booted. I can login via SSH and enter "/etc/init.d/tomcat55 start" and it will start.

I have set the runlevel to be 3, 5 and set it to run on boot via webmin also but to no avail. I even tried creating a cronjob that would run the tomcat55 start command on boot but it says "failed" even when I test it.

Any help would be greatly appreciated :)

4 Replies

Well, grep-ing the systom boot log for 'tomcat' might show an error message.

James

It turns out that the init script for tomcat on Suse 10.3 is flawed and will not work unless a user is actually logged in.

I finally just gave up and installed Tomcat 6.0.14 which incidentally is not available in an RPM but the installation is literally just untaring and putting it in some directory. Then it was just a matter of making a simple startup script:

#!/bin/bash
#
# tomcat  boot script

RETVAL=$?
CATALINA_HOME="/tomcat6"

export JAVA_HOME="/usr/lib/jvm/java"

    case $1 in
    start)
            sh /tomcat6/bin/startup.sh
            ;;
    stop)  
            sh /tomcat6/bin/shutdown.sh
            ;;
    restart)
            sh /tomcat6/bin/shutdown.sh
            sh /tomcat6/bin/startup.sh
            ;;
    esac   
    exit 0

Placing it in /etc/init.d, Chmod +X starttomcat.sh

For some reason it would still return errors when set to boot so I just added a cronjob that executed "/etc/init.d/starttomcat.sh start" on boot.

This may not be the most elegant solution but until the tomcat RPM is fixed this is the only thing that worked for me. (The premade boot script also fails to work on my full desktop Suse 10.3 install so this is not an isolated occurance)

This is probably a better solution anyway since I decided not to use Apache and route to tomcat. Tomcat 5 was the first version to have a built in component for serving static content, Tomcat 6 has since improved making apache not needed (unless one wants/needs PHP)

Dunno anything about SUSE, but I start Tomcat 5 from init using jsvc (http://commons.apache.org/daemon/jsvc.html). Jsvc is nice /c it lets you start Tomcat as any user, even one with no login shell (which is more secure).

I run Gentoo, but here's my init script which you should be able to easily adapt to SUSE:

#!/sbin/runscript
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

depend() {
        need net
        use apache dns logger netmount
        after sshd
}

configtest() {
        ebegin "Checking Apache Tomcat Configuration"
        checkconfig
        eend $?
}

checkconfig() {
        [ -z ${JAVA_HOME} ] && return 1
        [ -z ${CATALINA_HOME} ] && return 1
        [ -z ${CATALINA_BASE} ] && return 1
        return 0
}

start() {
        checkconfig || return 1
        ebegin "Starting tomcat"
        cd  ${CATALINA_HOME}
        bin/jsvc -home ${JAVA_HOME} \
            -Dcatalina.home=${CATALINA_HOME} \
            -Dcatalina.base=${CATALINA_BASE} \
            -Djava.endorsed.dirs=./common/endorsed \
            -Djava.io.tmpdir=${CATALINA_BASE}/temp \
            -cp ./bin/bootstrap.jar \
            -user apache \
            -wait 60 \
            -outfile ${CATALINA_BASE}/logs/catalina.out \
            -errfile ${CATALINA_BASE}/logs/catalina.err \
            -pidfile /var/run/tomcat.pid \
            org.apache.catalina.startup.Bootstrap
        eend $?
}

stop() {
        checkconfig || return 1
        ebegin "Stopping tomcat"
        cd  ${CATALINA_HOME}
        bin/jsvc -stop -home ${JAVA_HOME} \
            -Dcatalina.home=${CATALINA_HOME} \
            -Dcatalina.base=${CATALINA_BASE} \
            -Djava.endorsed.dirs=./common/endorsed \
            -Djava.io.tmpdir=${CATALINA_BASE}/temp \
            -cp ./bin/bootstrap.jar \
            -user apache \
            -wait 60 \
            -outfile ${CATALINA_BASE}/logs/catalina.out \
            -errfile ${CATALINA_BASE}/logs/catalina.err \
            -pidfile /var/run/tomcat.pid \
            org.apache.catalina.startup.Bootstrap
        eend $?
}

From adamzieba@gmail.com

Fri Apr 18 07:15:49 EDT 2008

Hi ZunZun,

Regarding http://www.linode.com/forums/viewtopic.php?p=13166 , the solution to the guy's problem is that, like ubuntu and I think Gentoo, SuSE uses something to manage its boot scripts.

*YaST2>System>System Services (Runlevel)>

*click on expert radio button,

*click on the service (You need to have copied it to the /etc/init.d folder 1st)

*click on the runlevel that you want (Probably 5).

I dont really want to register on the forum, so could you post the solution. SuSE is not my 1st choice but cron jobs are def my last.

Thanks,

Adam

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct