tomcat通过systemctl启动时报错Cannot find /usr/local/tomcat/bin/setclasspath.sh

解决方法,检查自己的CATALINA_HOME=和TOMCAT_HOME配置情况

我的配置在/etc/profile下的如下

使其立即生效

后将/usr/lib/systemd/system/tomcat.service中的CATALINA_HOME=和TOMCAT_HOME和/etc/profile改一致

重新加载再重启解决


解决方法,检查自己的CATALINA_HOME=和TOMCAT_HOME配置情况

我的配置在/etc/profile下的如下

[root@localhost bin]# tail -4 /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_371
export PATH=$JAVA_HOME/bin:$PATH
export CATALINA_HOME=/usr/local/tomcat/apache-tomcat-8.5.70
export TOMCAT_HOME=/usr/local/tomcat/apache-tomcat-8.5.70

使其立即生效

[root@localhost bin]# source /etc/profile

后将/usr/lib/systemd/system/tomcat.service中的CATALINA_HOME=和TOMCAT_HOME和/etc/profile改一致

[root@localhost system]# pwd 
/usr/lib/systemd/system
[root@localhost system]# cat tomcat.service 
# Systemd unit file for default tomcat
# 
# To create clones of this service:
# DO NOTHING, use [email protected] instead.

[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target

[Service]
Type=forking
Environment=JAVA_HOME=/usr/java/jdk1.8.0_371
Environment=CATALINA_HOME=/usr/local/tomcat/apache-tomcat-8.5.70
ExecStart=/usr/local/tomcat/apache-tomcat-8.5.70/bin/startup.sh
ExecStop=/usr/local/tomcat/apache-tomcat-8.5.70/bin/shutdown.sh
ExecReload=/bin/kill -s HUP $MAINPID
SuccessExitStatus=143
User=tomcat
Group=tomcat
PrivateTmp=true

[Install]
WantedBy=multi-user.target

重新加载再重启解决

[root@localhost system]# systemctl daemon-reload 
[root@localhost system]# systemctl restart tomcat
[root@localhost system]# systemctl status tomcat
● tomcat.service - Apache Tomcat Web Application Container
   Loaded: loaded (/usr/lib/systemd/system/tomcat.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2023-08-06 22:02:45 CST; 5s ago
  Process: 31233 ExecStop=/usr/local/tomcat/apache-tomcat-8.5.70/bin/shutdown.sh (code=exited, status=0/SUCCESS)
  Process: 31265 ExecStart=/usr/local/tomcat/apache-tomcat-8.5.70/bin/startup.sh (code=exited, status=0/SUCCESS)
 Main PID: 31272 (java)
   CGroup: /system.slice/tomcat.service
           └─31272 /usr/java/jdk1.8.0_371/bin/java -Djava.util....

Aug 06 22:02:45 localhost.localdomain systemd[1]: Starting Apac...
Aug 06 22:02:45 localhost.localdomain systemd[1]: Started Apach...
Hint: Some lines were ellipsized, use -l to show in full.

你可能感兴趣的:(tomcat,Linux,tomcat,java,systemctl,setclasspath.sh)