我在我的Ubuntu 22.04机器上安装了Tomcat 8.5。我能够在localhost:8080上使用startup.sh文件和systemctl服务测试tomcat。但是,当我在tomcat上部署应用程序的war文件时,我无法连接到localhost:8080。systemctl status tomcat显示为active。
当我使用startup.sh手动启动我的tomcat时,我可以连接到localhost:8080和localhost:8080/myapp。
在比较了两种情况下的 Catalina .out日志后,我发现在手动启动tomcat时,我的日志文件会得到以下日志:
正在配置Spring Security Core..已完成配置Spring Security Core
我可以使用tomcat连接到我的应用程序。但是,每当我使用systemctl启动tomcat时,tomcat就开始运行了,但我永远无法访问它。在这种情况下,我的日志文件没有Spring Security Core行。
下面是我的systemctl文件:
[Unit]
Description=Tomcat 8.5
After=syslog.target network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
Environment="JAVA_HOME=/home/myuser/.sdkman/candidates/java/8.0.282.hs-adpt"
Environment="JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom"
Environment="CATALINA_PID=/opt/tomcat/temp/tomcat.pid"
Environment="CATALINA_BASE=/opt/tomcat"
Environment="CATALINA_HOME=/opt/tomcat"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
#RestartSec=10
#Restart=always
[Install]
WantedBy=multi-user.target
没有与tomcat用户权限和所有权相关的问题,因为我可以使用以下命令启动并连接到我的应用程序:
sudo -u tomcat bash -c '/opt/tomcat/bin/startup.sh'
编辑:
journalctl输出:
An ExecStart= process belonging to unit tomcat.service has exited.
░░ ░░ The process' exit code is 'exited' and its exit status is 1.
Aug 21 14:44:49 myMachine systemd[1]: tomcat.service: Failed with result 'exit-code'.
░░ Subject: Unit failed ░░ Defined-By: systemd ░░
Support: http://www.ubuntu.com/support
░░ ░░ The unit tomcat.service has entered the 'failed' state with result 'exit-code'.
Aug 21 14:44:49 myMachine systemd[1]: Failed to start Tomcat - instance .
░░ Subject: A start job for unit tomcat.service has failed ░░
Defined-By: systemd ░░ Support: http://www.ubuntu.com/support
░░ ░░ A start job for unit tomcat.service has finished with a failure. ░░ ░░
The job identifier is 14172 and the job result is failed.
1条答案
按热度按时间cdmah0mi1#
我强迫我的tomcat给我给予一个日志错误,并在这里进行这些步骤和工作(Ubuntu 22.04)
1.添加一个tomcat用户(如果您跳过此操作)
1.授予权限
1.编辑我的系统
1.安装systemd守护程序
1.尝试启动
在这工作之后,我很好。