在 Ubuntu 18 上启动 Tomcat 9 出错

在 Ubuntu 18 上启动 Tomcat 9 出错

我正在尝试在运行 Ubuntu 18.04.4 LTS 的 64 位计算机上安装 apache-tomcat-9.0.33。我按照https://linuxize.com/post/how-to-install-tomcat-9-on-ubuntu-18-04/一切进行得很顺利,直到第 4 步快结束时。当我尝试启动 tomcat 时,我得到了以下信息:

~$ sudo systemctl start tomcat
Job for tomcat.service failed because the control process exited with error code.
See "systemctl status tomcat.service" and "journalctl -xe" for details.

这些命令的输出表明问题是由不正确的权限引起的。

我执行了以下所有建议:

无法在 Ubuntu 16.04 上启动 Apache Tomcat 8.5.4

现在,/opt/tomcat/bin/ 中每个 .sh 文件的权限都设置为“-rwxr-xr-x”,并且该目录下的每个文件的所有者和组均为“tomcat”。此外,路径 /opt/tomcat/bin/ 中的每个目录的所有者和组权限均为“drwxr-xr-x”,而所有者和组权限均为“tomcat”。

我检查了 /etc/systemd/system/tomcat.service 中给出的 JAVA_HOME 值与 printenv JAVA_HOME 给出的值相同。

启动还是失败。

我重新启动了机器,检查没有过时的 pid,然后重试,但启动失败:

~$ ps ax | grep tomcat
 4795 tty2     Sl+    0:16 gedit /home/coffeepot/Desktop/tomcat fail 1.txt
 5379 pts/0    S+     0:00 grep --color=auto tomcat

~$ sudo systemctl start tomcat
Job for tomcat.service failed because the control process exited with error code.
See "systemctl status tomcat.service" and "journalctl -xe" for details.

sudo systemctl status tomcat
● tomcat.service - Apache Tomcat Web Application Container
   Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2020-04-21 09:58:12 EDT; 15s ago
  Process: 5233 ExecStart=/opt/tomcat/latest/bin/startup.sh (code=exited, status=0/SUCCESS)
 Main PID: 5243 (code=exited, status=2)

Apr 21 09:58:12 m11 systemd[1]: Starting Apache Tomcat Web Application Container...
Apr 21 09:58:12 m11 startup.sh[5233]: Existing PID file found during start.
Apr 21 09:58:12 m11 startup.sh[5233]: Removing/clearing stale PID file.
Apr 21 09:58:12 m11 startup.sh[5233]: Tomcat started.
Apr 21 09:58:12 m11 systemd[1]: Started Apache Tomcat Web Application Container.
Apr 21 09:58:12 m11 systemd[1]: tomcat.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Apr 21 09:58:12 m11 systemd[1]: tomcat.service: Failed with result 'exit-code'.

journalctl -xe
-- 
-- The result is RESULT.
Apr 21 09:58:11 m11 systemd[1]: Dependency failed for /mnt/28db1409-5a51-40d2-84ad-3b4496c805ec.
-- Subject: Unit mnt-28db1409\x2d5a51\x2d40d2\x2d84ad\x2d3b4496c805ec.mount has failed
-- Defined-By: systemd
-- Support: 
-- 
-- Unit mnt-28db1409\x2d5a51\x2d40d2\x2d84ad\x2d3b4496c805ec.mount has failed.
-- 
-- The result is RESULT.
Apr 21 09:58:11 m11 systemd[1]: mnt-28db1409\x2d5a51\x2d40d2\x2d84ad\x2d3b4496c805ec.mount: Job mnt-28db1409\x2d5a51\x2d40d2\x2d84ad\x2d3b4496c805ec.mount/start failed with result 'dependency'.
Apr 21 09:58:11 m11 systemd[1]: dev-disk-by\x2duuid-28db1409\x2d5a51\x2d40d2\x2d84ad\x2d3b4496c805ec.device: Job dev-disk-by\x2duuid-28db1409\x2d5a51\x2d40d2\x2d84ad\x2d3b4496c805ec.device/start failed with
Apr 21 09:58:12 m11 sudo[5230]: coffeepot : TTY=pts/0 ; PWD=/home/coffeepot ; USER=root ; COMMAND=/bin/systemctl start tomcat
Apr 21 09:58:12 m11 sudo[5230]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 21 09:58:12 m11 systemd[1]: Starting Apache Tomcat Web Application Container...
-- Subject: Unit tomcat.service has begun start-up
-- Defined-By: systemd
-- Support: 
-- 
-- Unit tomcat.service has begun starting up.
Apr 21 09:58:12 m11 startup.sh[5233]: Existing PID file found during start.
Apr 21 09:58:12 m11 startup.sh[5233]: Removing/clearing stale PID file.
Apr 21 09:58:12 m11 startup.sh[5233]: Tomcat started.
Apr 21 09:58:12 m11 systemd[1]: Started Apache Tomcat Web Application Container.
-- Subject: Unit tomcat.service has finished start-up
-- Defined-By: systemd
-- Support: 
-- 
-- Unit tomcat.service has finished starting up.
-- 
-- The start-up result is RESULT.
Apr 21 09:58:12 m11 systemd[1]: tomcat.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Apr 21 09:58:12 m11 systemd[1]: tomcat.service: Failed with result 'exit-code'.
Apr 21 09:58:12 m11 sudo[5230]: pam_unix(sudo:session): session closed for user root
Apr 21 09:58:17 m11 gnome-shell[4476]: Ignoring excess values in shadow definition
Apr 21 09:58:17 m11 gnome-shell[4476]: Ignoring excess values in shadow definition
Apr 21 09:58:17 m11 gnome-shell[4476]: Ignoring excess values in shadow definition
Apr 21 09:58:17 m11 gnome-shell[4476]: Ignoring excess values in shadow definition
Apr 21 09:58:18 m11 gnome-shell[4476]: Ignoring excess values in shadow definition
Apr 21 09:58:18 m11 gnome-shell[4476]: Ignoring excess values in shadow definition
Apr 21 09:58:19 m11 gnome-shell[4476]: Ignoring excess values in shadow definition
Apr 21 09:58:19 m11 gnome-shell[4476]: Ignoring excess values in shadow definition
Apr 21 09:58:19 m11 gnome-shell[4476]: Ignoring excess values in shadow definition
Apr 21 09:58:19 m11 gnome-shell[4476]: Ignoring excess values in shadow definition
Apr 21 09:58:19 m11 gnome-shell[4476]: Ignoring excess values in shadow definition
Apr 21 09:58:19 m11 gnome-shell[4476]: Ignoring excess values in shadow definition
Apr 21 09:58:28 m11 sudo[5245]: coffeepot : TTY=pts/0 ; PWD=/home/coffeepot ; USER=root ; COMMAND=/bin/systemctl status tomcat
Apr 21 09:58:28 m11 sudo[5245]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 21 09:58:28 m11 sudo[5245]: pam_unix(sudo:session): session closed for user root
Apr 21 09:58:43 m11 gnome-shell[4476]: Ignoring excess values in shadow definition
Apr 21 09:58:43 m11 gnome-shell[4476]: Ignoring excess values in shadow definition
Apr 21 09:58:43 m11 gnome-shell[4476]: Ignoring excess values in shadow definition
Apr 21 09:58:43 m11 gnome-shell[4476]: Ignoring excess values in shadow definition
Apr 21 09:58:48 m11 PackageKit[1334]: get-updates transaction /1028_ecebadde from uid 1000 finished with success after 398ms

我遗漏了什么?如何让 tomcat 工作?

答案1

我找到了问题的原因。当我仔细查看 Catalina 日志时,我发现我在 JAVA_HOME 中的路径中添加了一个额外的斜杠,导致 Tomcat 无法找到 Java。

相关内容