centos 7配置tomcat自启动时报以下错误
Job for tomcat.service failed because the control process exited with error code. See "systemctl status tomcat.service" and "journalctl -xe" for details.
使用systemctl status tomcat.service
命令查看报错信息
报错提示说是缺少JAVA_HOME或JRE_HOME环境变量,就算在/etc/profile下配置了,tomcat也加载不到,这时要在tomcat的bin下找到一个名为setclasspath.sh的文件
tomcat启动的大致流程是startup.sh->catalina.sh->setclasspath.sh,而setclasspath.sh的作用就是加载环境变量
可以看到脚本执行的第一句就是去加载环境变量,所以需要在最前面加入JAVA_HOME
重新执行systemctl start tomcat就可以运行成功了