Tomcat8正在运行,但状态是Tomcat servlet引擎未运行

时间:2017-05-26 02:40:47

标签: linux debian tomcat8

我对tomcat现在的工作方式感到困惑。

当我尝试启动"sudo service tomcat8 start""sudo /etc/init.d/tomcat8 start"时,我收到错误"[FAIL] Starting Tomcat servlet engine: tomcat8 failed!"。日志中没有错误。

如果我执行"sh catalina.sh run",我会

Using CATALINA_BASE:   /usr/share/tomcat8
Using CATALINA_HOME:   /usr/share/tomcat8
Using CATALINA_TMPDIR: /usr/share/tomcat8/temp
Using JRE_HOME:        /usr/lib/jvm/jdk-8-oracle-x64/jre
Using CLASSPATH:       /usr/share/tomcat8/bin/bootstrap.jar:/usr/share/tomcat8/bin/tomcat-juli.jar
May 26, 2017 8:05:10 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat8/common/classes], exists: [false], isDirectory: [false], canRead: [false]
May 26, 2017 8:05:10 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat8/common], exists: [false], isDirectory: [false], canRead: [false]
May 26, 2017 8:05:10 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat8/server/classes], exists: [false], isDirectory: [false], canRead: [false]
May 26, 2017 8:05:10 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat8/server], exists: [false], isDirectory: [false], canRead: [false]
May 26, 2017 8:05:10 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat8/shared/classes], exists: [false], isDirectory: [false], canRead: [false]
May 26, 2017 8:05:10 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat8/shared], exists: [false], isDirectory: [false], canRead: [false]
May 26, 2017 8:05:10 AM org.apache.catalina.startup.Catalina load
WARNING: Unable to load server configuration from [/usr/share/tomcat8/conf/server.xml]
May 26, 2017 8:05:10 AM org.apache.catalina.startup.Catalina load
WARNING: Unable to load server configuration from [/usr/share/tomcat8/conf/server.xml]
May 26, 2017 8:05:10 AM org.apache.catalina.startup.Catalina start
SEVERE: Cannot start server. Server instance is not configured.

如果我执行"sh startup.sh",我会

Using CATALINA_BASE:   /usr/share/tomcat8
Using CATALINA_HOME:   /usr/share/tomcat8
Using CATALINA_TMPDIR: /usr/share/tomcat8/temp
Using JRE_HOME:        /usr/lib/jvm/jdk-8-oracle-x64/jre
Using CLASSPATH:       /usr/share/tomcat8/bin/bootstrap.jar:/usr/share/tomcat8/bin/tomcat-juli.jar
Tomcat started.

只有在执行"sh startup.sh"项目后才能运行。但是,状态是

sudo service tomcat8 status
[ ok ] Tomcat servlet engine is not running..

WTF ??? 任何想法?

直到我发布脚本,这一切都完美无缺。我们在另一个项目中使用这个脚本,它运行正常。

#!/bin/bash
#v2.5

url="jenkins/ROOT.war"

stop="/etc/init.d/tomcat8 stop"
start="/etc/init.d/tomcat8 start"
tmp_dir="/tmp/new-version"
tomcat_dir="/var/lib/tomcat8"
app_dir="$tomcat_dir/webapps"
cache="$tomcat_dir/work/Catalina"
log="$tomcat_dir/logs/catalina.out"

tomcat_user="tomcat"
tomcat_user="$tomcat_user"
log_dir="/var/log/new-version"
backup_dir="/home/tomcat"

if [ "$url" = "" ]; then
    echo "${url}"
else
    mkdir -p $log_dir
    rm -rf $tmp_dir
    mkdir -p $tmp_dir/ROOT
    cd $tmp_dir/ROOT
    application_file=$(echo $url | sed 's/.*\/\(.*\)/\1/')
    echo $application_file
    mv $application_file ROOT.war
    jar xf ROOT.war 2>&1 >> $log_dir/`date +%F`.log
    rm -rf ROOT.war
    jar cf ROOT.war *
    mv ROOT.war $tmp_dir/ROOT.war
    cd $tmp_dir
    echo "revision is prepared. Deploy it and restart tomcat?[y/n]"
    read answer

    if [ "$answer" = "y" ]; then
    $unmonitor
    sh $stop

    mv -f $log $log.`date +%F`.rev.$old_revision
    rm -rf $app_dir/ROOT $app_dir/ROOT.war $cache

    mv ROOT.war $app_dir/ROOT.war
    touch $log
    chown -R $tomcat_user:$tomcat_group $app_dir
        sh $start
    $monitor
        echo "Revision $new_revision is up and running!"
    echo "Now compressing old logs..."

        tar czf $log.`date +%F`.rev.$old_revision.tgz $log.`date +%F`.rev.$old_revision
    rm -rf $log.`date +%F`.rev.$old_revision
    cd ~
    rm -rf $tmp_dir

    echo "Done!"
    else
    echo "Aborted!"
    fi
fi

服务器信息

PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=debian
HOME_URL="http://www.debian.org/"

1 个答案:

答案 0 :(得分:0)

问题出在此行chown -R $tomcat_user:$tomcat_group $app_dir上,它使用的是tomcat user = tomcat而不是tomcat user = tomcat8。我更改了我的tomcat8用户的webapps目录权限。