Java Tomcat 不会在端口 8080 上响应
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18447930/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Tomcat won't respond on port 8080
提问by tessiof
Tomcat is listening on port 8080, but it do not respond correctly to HTTP requests. I'm running an updated Centos 6.2, and Tomcat is installed from the package tomcat6.
Tomcat 正在侦听端口 8080,但它没有正确响应 HTTP 请求。我正在运行更新的 Centos 6.2,并且从 tomcat6 包安装了 Tomcat。
Tomcat is running and listening on port 8080.
Tomcat 正在运行并侦听端口 8080。
# netstat -tlnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8009 0.0.0.0:* LISTEN 9214/java
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 9214/java
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 981/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1057/master
tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 9214/java
# ps aux | grep -i tomcat
tomcat 9214 0.0 10.0 164556 51516 ? Sl 15:00 0:01 /usr/lib/jvm/jre/bin/java -Djavax.sql.DataSource.Factory=org.apache.commons.dbcp.BasicDataSourceFactory -classpath :/usr/share/tomcat6/bin/bootstrap.jar:/usr/share/tomcat6/bin/tomcat-juli.jar:/usr/share/java/commons-daemon.jar -Dcatalina.base=/usr/share/tomcat6 -Dcatalina.home=/usr/share/tomcat6 -Djava.endorsed.dirs= -Djava.io.tmpdir=/var/cache/tomcat6/temp -Djava.util.logging.config.file=/usr/share/tomcat6/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager org.apache.catalina.startup.Bootstrap start
But when I connect to port 8080, I get a "Connection closed by foreign host" message:
但是当我连接到端口 8080 时,我收到一条“连接被外部主机关闭”消息:
# telnet localhost 8080
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /
Connection closed by foreign host.
It's important to note that it do connect to port 8080, but the connection is closed when anything is sent on the connection stream:
需要注意的是,它确实连接到端口 8080,但是当在连接流上发送任何内容时,连接将关闭:
# netstat -tnp
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:8080 127.0.0.1:54553 TIME_WAIT -
The logs show no error messages:
日志没有显示错误消息:
# tail /var/log/tomcat6/catalina.out
Aug 26, 2013 3:00:36 p.m. org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.24
Aug 26, 2013 3:00:36 p.m. org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Aug 26, 2013 3:00:36 p.m. org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Aug 26, 2013 3:00:36 p.m. org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/19 config=null
Aug 26, 2013 3:00:36 p.m. org.apache.catalina.startup.Catalina start
INFO: Server startup in 144 ms
# tail /var/log/messages
Aug 26 13:17:45 sugar yum[1120]: Installed: regexp-1.5-4.4.el6.i686
Aug 26 13:17:46 sugar yum[1120]: Installed: bcel-5.2-7.2.el6.i686
Aug 26 13:17:46 sugar yum[1120]: Installed: 1:mx4j-3.0.1-9.13.el6.noarch
Aug 26 13:17:46 sugar yum[1120]: Installed: tomcat6-lib-6.0.24-57.el6_4.noarch
Aug 26 13:17:46 sugar yum[1120]: Installed: tomcat6-6.0.24-57.el6_4.noarch
Aug 26 14:42:06 sugar kernel: ip_tables: (C) 2000-2006 Netfilter Core Team
Aug 26 14:44:07 sugar yum[8994]: Installed: gpm-libs-1.20.6-12.el6.i686
Aug 26 14:44:07 sugar yum[8994]: Installed: gc-7.1-10.el6.i686
Aug 26 14:44:08 sugar yum[8994]: Installed: w3m-0.5.2-16.el6.i686
Aug 26 14:54:07 sugar yum[9068]: Installed: 1:telnet-0.17-47.el6_3.1.i686
# pwd
/var/log/tomcat6
# ll
total 24
-rw-r--r-- 1 tomcat tomcat 8277 Aug 26 15:00 catalina.2013-08-26.log
-rw-r--r-- 1 tomcat tomcat 12112 Aug 26 15:31 catalina.out
-rw-r--r-- 1 tomcat tomcat 0 Aug 26 13:23 host-manager.2013-08-26.log
-rw-r--r-- 1 tomcat tomcat 0 Aug 26 13:23 localhost.2013-08-26.log
-rw-r--r-- 1 tomcat tomcat 0 Aug 26 13:23 manager.2013-08-26.log
For the peace of mind, I checked the firewall:
为了安心,我检查了防火墙:
# iptables -L -vn
Chain INPUT (policy ACCEPT 6042 packets, 1563K bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 4122 packets, 587K bytes)
pkts bytes target prot opt in out source destination
How can I do any further troubleshooting!? Thanks!
我该如何进行进一步的故障排除!?谢谢!
采纳答案by amit
It could be that you don't have any application deployed on your ROOT?
可能是您的 ROOT 上没有部署任何应用程序?
can you post the content of your /tomcat/webapps/*
?
你可以发布你的内容/tomcat/webapps/*
吗?
say you have application.war
deployed so you'd rather do
说你已经application.war
部署,所以你宁愿这样做
GET /application/something
I just tested on my working tomcat and when calling GET /
it also returns nothing because there is no application deployed over there (default for root in tomcat is /tomcat/webapps/ROOT
)
我刚刚在我的工作 tomcat 上进行了测试,在调用GET /
它时也没有返回任何内容,因为那里没有部署应用程序(tomcat 中的 root 的默认值为/tomcat/webapps/ROOT
)
Hope I could help.
希望我能帮上忙。