Package: tomcat8 Version: 8.0.14-1+deb8u2 Severity: normal Dear Maintainer,
I downloaded and started docker image with tomcat8 preinstalled: $ docker run -d -p 8080:8080 alkacon/opencms-docker:10.0.1 Loggin into the image and trying to stop the tomcat8 container fails and logs: # # Look for running instance id with 'docker ps'. E.g. 3186238ed456 $ docker exec -it 3186238ed456 /bin/bash root@3186238ed456:/# /etc/init.d/tomcat8 start > Stopping Tomcat servlet engine: tomcat8 (not running). Using the init daemon to restart the tomcat also fails: root@3186238ed456:/# /etc/init.d/tomcat8 stop > Stopping Tomcat servlet engine: tomcat8 (not running). Inspecting the /etc/init.d/tomcat8 script I have to admit that I'm really confused. I have annotated the code, so you can follow: case "$1" in 184 start) 184b # Sanity checks ... .... 194 195 log_daemon_msg "Starting $DESC" "$NAME" 196 if start-stop-daemon --test --start --pidfile "$CATALINA_PID" \ 197 --user $TOMCAT8_USER --exec "$JAVA_HOME/bin/java" \ 198 >/dev/null; then 198b # Acording to the man, start-stop-daemon --test always 198c # return 0 199 200 201 # Regenerate POLICY_CACHE file .... 208 209 # Remove / recreate JVM_TMP directory .... 216 216b # Starts tomcat 217 catalina_sh start $SECURITY 218 sleep 5 219 if start-stop-daemon --test --start --pidfile "$CATALINA_PID" \ 220 --user $TOMCAT8_USER --exec "$JAVA_HOME/bin/java" \ 221 >/dev/null; then 221b # Again, always 0. This "then" branch is always 221c # executed 222 if [ -f "$CATALINA_PID" ]; then 222b # XXX: why is the PID file deleted!? 223 rm -f "$CATALINA_PID" 224 fi 224b # XXX: This should be the success case and return 0? 225 log_end_msg 1 226 else 227 log_end_msg 0 228 fi If I get it correctly, after the sleep, the script enters always the "then" clause of the if, removes PID file and returns failure. I have testet switching the "then" and "else" clauses, and it works as expected. -- System Information: Debian Release: 8.5 APT prefers stable-updates APT policy: (500, 'stable-updates'), (500, 'stable') Architecture: amd64 (x86_64) Kernel: Linux 4.4.6-gentoo (SMP w/4 CPU cores) Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: unable to detect Versions of packages tomcat8 depends on: ii adduser 3.113+nmu3 ii debconf [debconf-2.0] 1.5.56 ii tomcat8-common 8.0.14-1+deb8u2 ii ucf 3.0030 Versions of packages tomcat8 recommends: pn authbind <none> Versions of packages tomcat8 suggests: pn libtcnative-1 <none> pn tomcat8-admin <none> pn tomcat8-docs <none> pn tomcat8-examples <none> pn tomcat8-user <none> -- Configuration Files: /etc/init.d/tomcat8 changed: set -e PATH=/bin:/usr/bin:/sbin:/usr/sbin NAME=tomcat8 DESC="Tomcat servlet engine" DEFAULT=/etc/default/$NAME JVM_TMP=/tmp/tomcat8-$NAME-tmp if [ `id -u` -ne 0 ]; then echo "You need root privileges to run this script" exit 1 fi if [ -r /etc/default/locale ]; then . /etc/default/locale export LANG fi .. /lib/lsb/init-functions if [ -r /etc/default/rcS ]; then . /etc/default/rcS fi TOMCAT8_USER=tomcat8 TOMCAT8_GROUP=tomcat8 find_jdks() { for java_version in 9 8 7 do for jvmdir in /usr/lib/jvm/java-${java_version}-openjdk-* \ /usr/lib/jvm/jdk-${java_version}-oracle-* \ /usr/lib/jvm/jre-${java_version}-oracle-* do if [ -d "${jvmdir}" ] then JDK_DIRS="${JDK_DIRS} ${jvmdir}" fi done done # Add older non multi arch installations JDK_DIRS="${JDK_DIRS} /usr/lib/jvm/java-7-oracle" } JDK_DIRS="/usr/lib/jvm/default-java" find_jdks for jdir in $JDK_DIRS; do if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then JAVA_HOME="$jdir" fi done export JAVA_HOME CATALINA_HOME=/usr/share/$NAME CATALINA_BASE=/var/lib/$NAME TOMCAT8_SECURITY=no if [ -z "$JAVA_OPTS" ]; then JAVA_OPTS="-Djava.awt.headless=true -Xmx128M" fi if [ -f "$DEFAULT" ]; then . "$DEFAULT" fi if [ ! -f "$CATALINA_HOME/bin/bootstrap.jar" ]; then log_failure_msg "$NAME is not installed" exit 1 fi POLICY_CACHE="$CATALINA_BASE/work/catalina.policy" if [ -z "$CATALINA_TMPDIR" ]; then CATALINA_TMPDIR="$JVM_TMP" fi if [ -n "$JSP_COMPILER" ]; then JAVA_OPTS="$JAVA_OPTS -Dbuild.compiler=\"$JSP_COMPILER\"" fi SECURITY="" if [ "$TOMCAT8_SECURITY" = "yes" ]; then SECURITY="-security" fi CATALINA_PID="/var/run/$NAME.pid" CATALINA_SH="$CATALINA_HOME/bin/catalina.sh" if [ -z "${JSSE_HOME}" -a -r "${JAVA_HOME}/jre/lib/jsse.jar" ]; then JSSE_HOME="${JAVA_HOME}/jre/" fi catalina_sh() { # Escape any double quotes in the value of JAVA_OPTS JAVA_OPTS="$(echo $JAVA_OPTS | sed 's/\"/\\\"/g')" AUTHBIND_COMMAND="" if [ "$AUTHBIND" = "yes" -a "$1" = "start" ]; then AUTHBIND_COMMAND="/usr/bin/authbind --deep /bin/bash -c " fi # Define the command to run Tomcat's catalina.sh as a daemon # set -a tells sh to export assigned variables to spawned shells. TOMCAT_SH="set -a; JAVA_HOME=\"$JAVA_HOME\"; source \"$DEFAULT\"; \ CATALINA_HOME=\"$CATALINA_HOME\"; \ CATALINA_BASE=\"$CATALINA_BASE\"; \ JAVA_OPTS=\"$JAVA_OPTS\"; \ CATALINA_PID=\"$CATALINA_PID\"; \ CATALINA_TMPDIR=\"$CATALINA_TMPDIR\"; \ LANG=\"$LANG\"; JSSE_HOME=\"$JSSE_HOME\"; \ cd \"$CATALINA_BASE\"; \ \"$CATALINA_SH\" $@" if [ "$AUTHBIND" = "yes" -a "$1" = "start" ]; then TOMCAT_SH="'$TOMCAT_SH'" fi # Run the catalina.sh script as a daemon set +e touch "$CATALINA_PID" "$CATALINA_BASE"/logs/catalina.out chown $TOMCAT8_USER "$CATALINA_PID" "$CATALINA_BASE"/logs/catalina.out start-stop-daemon --start -b -u "$TOMCAT8_USER" -g "$TOMCAT8_GROUP" \ -c "$TOMCAT8_USER" -d "$CATALINA_TMPDIR" -p "$CATALINA_PID" \ -x /bin/bash -- -c "$AUTHBIND_COMMAND $TOMCAT_SH" status="$?" set +a -e return $status } case "$1" in start) if [ -z "$JAVA_HOME" ]; then log_failure_msg "no JDK or JRE found - please set JAVA_HOME" exit 1 fi if [ ! -d "$CATALINA_BASE/conf" ]; then log_failure_msg "invalid CATALINA_BASE: $CATALINA_BASE" exit 1 fi log_daemon_msg "Starting $DESC" "$NAME" if start-stop-daemon --test --start --pidfile "$CATALINA_PID" \ --user $TOMCAT8_USER --exec "$JAVA_HOME/bin/java" \ >/dev/null; then # Regenerate POLICY_CACHE file umask 022 echo "// AUTO-GENERATED FILE from /etc/tomcat8/policy.d/" \ > "$POLICY_CACHE" echo "" >> "$POLICY_CACHE" cat $CATALINA_BASE/conf/policy.d/*.policy \ >> "$POLICY_CACHE" # Remove / recreate JVM_TMP directory rm -rf "$JVM_TMP" mkdir -p "$JVM_TMP" || { log_failure_msg "could not create JVM temporary directory" exit 1 } chown $TOMCAT8_USER "$JVM_TMP" catalina_sh start $SECURITY sleep 5 if start-stop-daemon --test --start --pidfile "$CATALINA_PID" \ --user $TOMCAT8_USER --exec "$JAVA_HOME/bin/java" \ >/dev/null; then if [ -f "$CATALINA_PID" ]; then # XXX: why do they delete this file # rm -f "$CATALINA_PID" echo "Deteting of $CATALINA_PID omited" fi # XXX: This should be the success case? # log_end_msg 1 log_end_msg 0 else log_end_msg 0 fi else log_progress_msg "(already running)" Log_end_msg 0 fi ;; stop) log_daemon_msg "Stopping $DESC" "$NAME" set +e if [ -f "$CATALINA_PID" ]; then start-stop-daemon --stop --pidfile "$CATALINA_PID" \ --user "$TOMCAT8_USER" \ --retry=TERM/20/KILL/5 >/dev/null if [ $? -eq 1 ]; then log_progress_msg "$DESC is not running but pid file exists, cleaning up" elif [ $? -eq 3 ]; then PID="`cat $CATALINA_PID`" log_failure_msg "Failed to stop $NAME (pid $PID)" exit 1 fi rm -f "$CATALINA_PID" rm -rf "$JVM_TMP" else log_progress_msg "(not running)" fi log_end_msg 0 set -e ;; status) set +e start-stop-daemon --test --start --pidfile "$CATALINA_PID" \ --user $TOMCAT8_USER --exec "$JAVA_HOME/bin/java" \ >/dev/null 2>&1 if [ "$?" = "0" ]; then if [ -f "$CATALINA_PID" ]; then log_success_msg "$DESC is not running, but pid file exists." exit 1 else log_success_msg "$DESC is not running." exit 3 fi else log_success_msg "$DESC is running with pid `cat $CATALINA_PID`" fi set -e ;; restart|force-reload) if [ -f "$CATALINA_PID" ]; then $0 stop sleep 1 fi $0 start ;; try-restart) if start-stop-daemon --test --start --pidfile "$CATALINA_PID" \ --user $TOMCAT8_USER --exec "$JAVA_HOME/bin/java" \ >/dev/null; then $0 start fi ;; *) log_success_msg "Usage: $0 {start|stop|restart|try-restart|force-reload|status}" exit 1 ;; esac exit 0 /etc/tomcat8/context.xml changed: <?xml version='1.0' encoding='utf-8'?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- The contents of this file will be loaded for each web application --> <Context sessionCookieName="JSESSIONID_3186238ed456"> <!-- Default set of monitored resources. If one of these changes, the --> <!-- web application will be reloaded. --> <WatchedResource>WEB-INF/web.xml</WatchedResource> <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource> <!-- Uncomment this to disable session persistence across Tomcat restarts --> <!-- <Manager pathname="" /> --> <!-- Uncomment this to enable Comet connection tacking (provides events on session expiration as well as webapp lifecycle) --> <!-- <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" /> --> </Context> /etc/tomcat8/server.xml changed: <?xml version='1.0' encoding='utf-8'?> <Server port="8005" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> <Service name="Catalina"> <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" /> <Engine name="Catalina" defaultHost="localhost"> <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> </Engine> </Service> </Server> -- debconf information: tomcat8/username: tomcat8 tomcat8/groupname: tomcat8 tomcat8/javaopts: -Djava.awt.headless=true -DDISPLAY=:0.0 -Xmx1536m -Xms256m -server -XX:+UseConcMarkSweepGC __ This is the maintainer address of Debian's Java team <http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-maintainers>. Please use debian-j...@lists.debian.org for discussions and questions.