使用ConnectException

时间:2019-01-25 13:37:37

标签: tomcat

我已经在带有Oracle OpenJDK11.0.2的Ubuntu 18.04.1上安装了Apache Tomcat 9.0.14。当我使用startup.shshutdown.sh时,Tomcat可以正常工作。

但是,当我尝试将Tomcat作为服务启动时,出现以下错误:

Jan 24 13:13:00 intr-test systemd[1]: Started Tomcat 9 servlet container.
-- Subject: Unit tomcat.service has finished start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit tomcat.service has finished starting up.
-- 
-- The start-up result is RESULT.
Jan 24 13:13:00 intr-test shutdown.sh[2362]: NOTE: Picked up JDK_JAVA_OPTIONS:  --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens
Jan 24 13:13:01 intr-test shutdown.sh[2362]: Jan 24, 2019 1:13:01 PM org.apache.catalina.startup.Catalina stopServer
Jan 24 13:13:01 intr-test shutdown.sh[2362]: SEVERE: Could not contact [localhost:8005] (base port [8005] and offset [0]). Tomcat may not be running.
Jan 24 13:13:01 intr-test shutdown.sh[2362]: Jan 24, 2019 1:13:01 PM org.apache.catalina.startup.Catalina stopServer
Jan 24 13:13:01 intr-test shutdown.sh[2362]: SEVERE: Error stopping Catalina
Jan 24 13:13:01 intr-test shutdown.sh[2362]: java.net.ConnectException: Connection refused (Connection refused)
Jan 24 13:13:01 intr-test shutdown.sh[2362]:         at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
Jan 24 13:13:01 intr-test shutdown.sh[2362]:         at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
Jan 24 13:13:01 intr-test shutdown.sh[2362]:         at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
Jan 24 13:13:01 intr-test shutdown.sh[2362]:         at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
Jan 24 13:13:01 intr-test shutdown.sh[2362]:         at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)
Jan 24 13:13:01 intr-test shutdown.sh[2362]:         at java.base/java.net.Socket.connect(Socket.java:591)
Jan 24 13:13:01 intr-test shutdown.sh[2362]:         at java.base/java.net.Socket.connect(Socket.java:540)
Jan 24 13:13:01 intr-test shutdown.sh[2362]:         at java.base/java.net.Socket.<init>(Socket.java:436)
Jan 24 13:13:01 intr-test shutdown.sh[2362]:         at java.base/java.net.Socket.<init>(Socket.java:213)
Jan 24 13:13:01 intr-test shutdown.sh[2362]:         at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:513)
Jan 24 13:13:01 intr-test shutdown.sh[2362]:         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Jan 24 13:13:01 intr-test shutdown.sh[2362]:         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
Jan 24 13:13:01 intr-test shutdown.sh[2362]:         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Jan 24 13:13:01 intr-test shutdown.sh[2362]:         at java.base/java.lang.reflect.Method.invoke(Method.java:566)
Jan 24 13:13:01 intr-test shutdown.sh[2362]:         at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:403)
Jan 24 13:13:01 intr-test shutdown.sh[2362]:         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:497)
Jan 24 13:13:01 intr-test shutdown.sh[2362]: The stop command failed. Attempting to signal the process to stop through OS signal.
Jan 24 13:13:02 intr-test shutdown.sh[2362]: Tomcat stopped.

我的systemd单位文件:

[Unit]
Description=Tomcat Container
After=network.target

[Service]
Type=forking

User=user
Group=user

Environment=JAVA_HOME=/usr/lib/jvm/jdk-11.0.2
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'

Environment=CATALINA_BASE=/home/user/apache-tomcat-9.0.14
Environment=CATALINA_HOME=/home/user/apache-tomcat-9.0.14
Environment=CATALINA_PID=/home/user/apache-tomcat-9.0.14/temp/tomcat.pid
Environment='CATALINA_OPTS=-Xms256M -Xmx512M -server -XX:+UseParallelGC'

ExecStart=/home/user/apache-tomcat-9.0.14/bin/startup.sh
ExecStop=/home/user/apache-tomcat-9.0.14/bin/shutdown.sh

[Install]
WantedBy=multi-user.target

有人知道这里的问题吗?

谢谢!

0 个答案:

没有答案