在tomcat8中启动.war servlet

时间:2016-03-29 12:48:25

标签: java maven servlets tomcat8 ubuntu-15.10

我有一个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'.
➜  ~ 

1 个答案:

答案 0 :(得分:1)

我发现终端输出在这里有点误导。显然有一个名为Catalina.log的日志文件(在ubuntu上默认为/var/lib/tomcat8/conf/catalina.log)。这就是我遇到麻烦的真正原因所在。显然我的server.xml配置存在问题(文件丢失)。

这里有更广泛的教训 - 在遇到tomcat问题时检查你的catalina.log