我对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..

世界跆拳道联盟???有什么想法吗?
昨天一切都很顺利,直到我开始写剧本。我们在其他项目中使用的这个脚本工作得很好。
#!/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/"

最佳答案

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

10-06 10:18