tomcat启动报错Cannot find usrlocaltomcatbinsetclasspath.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导致的。

解决:

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

vi  /etc/profile

2.修改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

3.设置环境变量立即生效:

source /etc/profile

4.最后再启动tomcat就好啦

5.如果你的tomcat是使用 docker 安装启动报这个错的话:

docker中此报错的其他解决办法你可以参考其他文章:
Latest image incompatible with old versions of docker engine
Tomcat 9 running on docker - Cannot find /usr/local/tomcat/bin/setclasspath.sh
Tomcat 9 running on docker - Cannot find /usr/local/tomcat/bin/setclasspath.sh

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值