tomcat启动报错Cannot find /usr/local/tomcat/bin/setclasspath.sh原因

在用命令

./startup.sh

启动tomcat时报错:

Cannot find /usr/local/tomcat/bin/setclasspath.sh
This file is needed to run this program

在tomcat的bin目录下我们看下catalina.sh文件:

vi catalina.sh

搜索下setclasspath:

?setclasspath

然后我们定位到搜索的地方:

if $os400; then
  # -r will Only work on the os400 if the files are:
  # 1. owned by the user
  # 2. owned by the PRIMARY group of the user
  # this will not work if the user belongs in secondary groups
  . "$CATALINA_HOME"/bin/setclasspath.sh
else
  if [ -r "$CATALINA_HOME"/bin/setclasspath.sh ]; then
    . "$CATALINA_HOME"/bin/setclasspath.sh
  else
    echo "Cannot find $CATALINA_HOME/bin/setclasspath.sh"
    echo "This file is needed to run this program"
    exit 1
  fi
fi

报这个错是因为$CATALINA_HOME配置的有问题导致无法找到/bin/setclasspath.sh导致的。

解决:

因为$CATALINA_HOME是配置在/etc/profile中的,所以我们修改下/etc/profile:

vi  /etc/profile

修改tomcat的配置信息TOMCAT_HOME和CATALINA_HOME为自己的tomcat文件位置,我的是下面这样:

export TOMCAT_HOME=/usr/local/tomcat/apache-tomcat-9.0.40
export CATALINA_HOME=/usr/local/tomcat/apache-tomcat-9.0.40

设置环境变量立即生效:

source /etc/profile

最后再启动tomcat就好啦

猜你喜欢

转载自blog.csdn.net/qq_33697094/article/details/110520236