CentOS, Tomcat 6 failed and won’t start – java issue

centosjavatomcat6

Linux isn't my strong suit so bear with me if this seems a little newbish. I have a virtual linux box rented, has CentOS (not sure which version) and Apache with Tomcat 6.

Over the past 24 hours, the Tomcat process failed and will not start again. I don't know why, because it had been working fine and I made no changes to the server operation (no updates or new software of anything)

The following information is available to me, but unfortunately does not point me to a solution:

When I try to start the tomcat6 service (service tomcat6 start) it says OK, but when I check its status, (service tomcat6 status) it says "PID file exists, but process is not running"

The catalina.out file records something like this each time I try to start it:
/usr/sbin/tomcat6/: line 30: -Duser.language=en: command not found
(sometimes the 30 will be a 60).

Edited to Add: the new/relevant events in catalina.out are:

/usr/sbin/tomcat6: line 60: -Duser.language=en: command not found
/usr/sbin/tomcat6: line 30: -Duser.language=en: command not found
/usr/sbin/tomcat6: line 30: -Duser.language=en: command not found
/usr/sbin/tomcat6: line 30: -Duser.language=en: command not found
/usr/sbin/tomcat6: line 60: -Duser.language=en: command not found
/usr/sbin/tomcat6: line 60: -Duser.language=en: command not found
/usr/sbin/tomcat6: line 30: -Duser.language=en: command not found
/usr/sbin/tomcat6: line 30: -Duser.language=en: command not found
/usr/sbin/tomcat6: line 60: -Duser.language=en: command not found
/usr/sbin/tomcat6: line 60: -Duser.language=en: command not found
/usr/sbin/tomcat6: line 30: -Duser.language=en: command not found
/usr/sbin/tomcat6: line 30: -Duser.language=en: command not found
/usr/sbin/tomcat6: line 60: -Duser.language=en: command not found
/usr/sbin/tomcat6: line 30: -Duser.language=en: command not found

In /var/log/tomcat6-initd.log I see the following complaint:

/usr/sbin/tomcat6: error: Failed to set JAVACMD. 

The full log of this file is:

/usr/sbin/tomcat6: error: Failed to set JAVACMD
/usr/sbin/tomcat6: error: Failed to set JAVACMD
/usr/sbin/tomcat6: error: Failed to set JAVACMD
/usr/sbin/tomcat6: error: Failed to set JAVACMD
/usr/sbin/tomcat6: error: Failed to set JAVACMD
/usr/sbin/tomcat6: error: Failed to set JAVACMD
/usr/sbin/tomcat6: error: Failed to set JAVACMD
/usr/sbin/tomcat6: error: Failed to set JAVACMD
/usr/sbin/tomcat6: error: Failed to set JAVACMD
/usr/sbin/tomcat6: error: Failed to set JAVACMD
/usr/sbin/tomcat6: error: Failed to set JAVACMD
/usr/sbin/tomcat6: error: Failed to set JAVACMD
/usr/sbin/tomcat6: error: Failed to set JAVACMD
/usr/sbin/tomcat6: error: Failed to set JAVACMD

No other logs have been updated since this started

I've tried restarting the machine, both through an online console and in a PuTTy session, and I've tried deleting the tomcat process id file (saw that somewhere someone had what looked like a similar problem) none of it worked, as you can imagine I also tried to start tomcat6 on multiple occasions, each time with no success.

Has anyone seen anything like this? Or might be able to help me figure out what's going on?

Edit: I've also added an extract from /usr/sbin/tomcat6, hope this formats correctly, I believe it's the section of the file that responds if you use service tomcat6 start.

    if [ "$1" = "start" ]; then
  ${JAVACMD} $JAVA_OPTS $CATALINA_OPTS \
    -classpath "$CLASSPATH" \
    -Dcatalina.base="$CATALINA_BASE" \
    -Dcatalina.home="$CATALINA_HOME" \
    -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \
    -Djava.io.tmpdir="$CATALINA_TMPDIR" \
    -Djava.util.logging.config.file="${CATALINA_BASE}/conf/logging.properties" \
    -Djava.util.logging.manager="org.apache.juli.ClassLoaderLogManager" \
    org.apache.catalina.startup.Bootstrap start \
    >> ${CATALINA_BASE}/logs/catalina.out 2>&1 &
    if [ ! -z "$CATALINA_PID" ]; then
      echo $! > $CATALINA_PID
    fi

Best Answer

/usr/sbin/tomcat6: error: Failed to set JAVACMD

It looks like your system is failing to define JAVACMD which in turn leads to

/usr/sbin/tomcat6: line 60: -Duser.language=en: command not found

because JAVACMD is null the system tries to run -Duser.language=en.

JAVACMD is defined (or not) in /usr/share/java-utils/java-functions

  # Add all sorts of jvm layouts here
  if [ -x "$JAVA_HOME/jre/sh/java" ]; then
    JAVACMD="$JAVA_HOME/jre/sh/java"
  elif [ -x "$JAVA_HOME/bin/java" ]; then
    JAVACMD="$JAVA_HOME/bin/java"
  else
    JAVACMD=`which java 2>/dev/null`
  fi

  if [ ! -x "$JAVACMD" ]; then
    echo "$0: error: Failed to set JAVACMD"
    return 1
  fi

So it seems that you have no valid java command in the places that tomcat is looking.