我有一个servlet应用程序,正试图部署到本地tomcat实例中。起初,我尝试使用tomcat管理器应用程序进行部署,但被告知有一种更简单的方法——只需将.war
放在webapps
-文件夹中。(我的机器上的/etc/tomcat8/webapps/
)
在重新启动tomcat服务时,我得到了一个错误:
Job for tomcat8.service failed because the control process exited with error code. See "systemctl status tomcat8.service" and "journalctl -xe" for details.
journalctl-xe输出如下:
......
session opened for user root by martini(uid=0)
mar 29 14:23:17 martini-XPS-13-9350 polkitd(authority=local)[737]: Registered Authentication Agent for unix-process:9719:7772642 (system bus name :1.160 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)
mar 29 14:23:17 martini-XPS-13-9350 systemd[1]: Stopped LSB: Start Tomcat..
-- Subject: Unit tomcat8.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit tomcat8.service has finished shutting down.
mar 29 14:23:17 martini-XPS-13-9350 systemd[1]: Starting LSB: Start Tomcat....
-- Subject: Unit tomcat8.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit tomcat8.service has begun starting up.
mar 29 14:23:17 martini-XPS-13-9350 tomcat8[9728]: * Starting Tomcat servlet engine tomcat8
mar 29 14:23:22 martini-XPS-13-9350 tomcat8[9728]: ...fail!
mar 29 14:23:22 martini-XPS-13-9350 systemd[1]: tomcat8.service: Control process exited, code=exited status=1
mar 29 14:23:22 martini-XPS-13-9350 systemd[1]: Failed to start LSB: Start Tomcat..
-- Subject: Unit tomcat8.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit tomcat8.service has failed.
--
-- The result is failed.
mar 29 14:23:22 martini-XPS-13-9350 systemd[1]: tomcat8.service: Unit entered failed state.
mar 29 14:23:22 martini-XPS-13-9350 systemd[1]: tomcat8.service: Failed with result 'exit-code'.
mar 29 14:23:22 martini-XPS-13-9350 polkitd(authority=local)[737]: Unregistered Authentication Agent for unix-process:9719:7772642 (system bus name :1.160, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
mar 29 14:23:22 martini-XPS-13-9350 sudo[9718]: pam_unix(sudo:session): session closed for user root
我怀疑这是我的本地环境(新安装的)上的配置错误,但我不知道它可能是什么!我试着重新安装,但过了一段时间,我又陷入了同样的死胡同。。。有什么想法吗?
编辑:这是systemctl status tomcat8.service
:的输出
➜ ~ systemctl status tomcat8.service
● tomcat8.service - LSB: Start Tomcat.
Loaded: loaded (/etc/init.d/tomcat8)
Active: failed (Result: exit-code) since tis 2016-03-29 17:05:45 CEST; 14s ago
Docs: man:systemd-sysv-generator(8)
Process: 3724 ExecStart=/etc/init.d/tomcat8 start (code=exited, status=1/FAILURE)
mar 29 17:05:40 martini-XPS-13-9350 systemd[1]: Stopped LSB: Start Tomcat..
mar 29 17:05:40 martini-XPS-13-9350 systemd[1]: Starting LSB: Start Tomcat....
mar 29 17:05:40 martini-XPS-13-9350 tomcat8[3724]: * Starting Tomcat servlet engine tomcat8
mar 29 17:05:45 martini-XPS-13-9350 tomcat8[3724]: ...fail!
mar 29 17:05:45 martini-XPS-13-9350 systemd[1]: tomcat8.service: Control process exited, code=exited status=1
mar 29 17:05:45 martini-XPS-13-9350 systemd[1]: Failed to start LSB: Start Tomcat..
mar 29 17:05:45 martini-XPS-13-9350 systemd[1]: tomcat8.service: Unit entered failed state.
mar 29 17:05:45 martini-XPS-13-9350 systemd[1]: tomcat8.service: Failed with result 'exit-code'.
➜ ~
我发现这里的终端输出有点误导。显然,有一个名为Catalina.log的日志文件(默认为ubuntu上的/var/lib/tomcat8/conf/catalina.log
)。这就是我遇到麻烦的真正原因。显然,我的server.xml配置出现了问题(文件丢失)。
这里更广泛的教训是-当遇到tomcat的麻烦时,检查您的catalina.log
!