java - Tomcat 不会在端口 8080 上响应

标签 java linux tomcat centos

Tomcat 正在监听端口 8080,但它无法正确响应 HTTP 请求。 我正在运行更新的 Centos 6.2,并且 Tomcat 是从包 tomcat6 安装的。

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

但是当我连接到端口 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.           

重要的是要注意它确实连接到端口 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   -  

日志显示没有错误消息:

# 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

为了安心,我检查了防火墙:

# 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   

我怎样才能做进一步的故障排除!? 谢谢!

最佳答案

可能是您的 ROOT 上没有部署任何应用程序?

你能发布你的/tomcat/webapps/*的内容吗?

假设您部署了 application.war,所以您宁愿这样做

GET /application/something

我刚刚在我的工作 tomcat 上进行了测试,当调用 GET/ 它也没有返回任何内容,因为那里没有部署应用程序(tomcat 中 root 的默认值为 /tomcat/webapps/ROOT )

希望我能帮上忙。

关于java - Tomcat 不会在端口 8080 上响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18447930/

相关文章:

Java,Eclipse 不接受自定义异常

java - 从源代码树构建android框架时的输出是什么

linux - 如何在 Amazon Linux AMI 中安装 Postgresql 11?

tomcat - 如何修复 Solr 异常 : Could not find necessary SLF4j logging jars?

java - 我可以在 Tomcat 上加载 servlet 类之前运行代码吗?

java - ImageLoader:连接超时

java - GWT - 如何在 @Entity 注释的类之外实现 RequestContext 方法?

linux - CentOS 7 Apachect1 移除虚拟主机

c - 我尝试进行的新系统调用有问题(Ubuntu 18.04.1 LTS 内核 :4. 17.4)

GWT 的 Spring Security JDBC 驱动程序 "no suitable driver"错误