简体   繁体   English

tomcat 正在运行,但是 8080 端口没有响应

[英]tomcat running ,but 8080 port not responding

I have installed sun jdk 1.6 x64 and tomcat in a linux x64 machine through ssh, i don't have root privileges so i installed both in my home dir.我已经通过 ssh 在 linux x64 机器上安装了 sun jdk 1.6 x64 和 tomcat,我没有 root 权限,所以我都安装在我的家庭目录中。

I managed to successful run tomcat but if i try to enter mydomain.com:8080 there's no answer from the server.我设法成功运行了 tomcat,但是如果我尝试输入 mydomain.com:8080,则服务器没有响应。

With this command:使用此命令:

netstat -atnp|grep LISTEN

i checked the port and it is LISTENING我检查了端口,它正在侦听

Dec 18, 2011 5:11:20 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /home2/fiegmund/jdk1.6.0_25/jre/lib/amd64/server:/home2/fiegmund/jdk1.6.0_25/jre/lib/amd64:/home2/fiegmund/jdk1.6.0_25/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Dec 18, 2011 5:11:21 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Dec 18, 2011 5:11:21 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Dec 18, 2011 5:11:21 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2015 ms
Dec 18, 2011 5:11:21 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Dec 18, 2011 5:11:21 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.23
Dec 18, 2011 5:11:21 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /home2/fiegmund/apache-tomcat-7.0.23/webapps/docs
Dec 18, 2011 5:11:24 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [1,869] milliseconds.
Dec 18, 2011 5:11:24 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /home2/fiegmund/apache-tomcat-7.0.23/webapps/manager
Dec 18, 2011 5:11:24 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /home2/fiegmund/apache-tomcat-7.0.23/webapps/ROOT
Dec 18, 2011 5:11:24 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /home2/fiegmund/apache-tomcat-7.0.23/webapps/examples
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/permittedTaglibs is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /home2/fiegmund/apache-tomcat-7.0.23/webapps/host-manager
Dec 18, 2011 5:11:25 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Dec 18, 2011 5:11:25 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4582 ms>

Any ideas of what is the problem?任何想法是什么问题?

Thanks in advance and sorry for the terrible english I wrote.预先感谢并为我写的糟糕的英语感到抱歉。

First step is to run telnet localhost 8080 when logged in locally.第一步是在本地登录时运行 telnet localhost 8080 。 Then type in something like然后输入类似的东西

GET /

and you should get HTML back.你应该找回 HTML。 If that doesn't work, then tomcat is not really running properly or is not listening on port 8080. If that works but when trying from outside, make sure that you have the correct ip address.如果这不起作用,则 tomcat 没有真正正常运行或未在端口 8080 上侦听。如果可行,但从外部尝试时,请确保您拥有正确的 IP 地址。 Try with ip address first.先用ip地址试试。 If ip address works, perhaps your mydomain.com doesn't resolve to it.如果 ip 地址有效,可能您的 mydomain.com 无法解析它。 If ip is correct (the same one you are ssh'ing to) and it still doesn' work, then you are probably running firewall which doesn't allow 8080 through.如果 ip 正确(与您正在使用的 ssh 相同)并且它仍然不起作用,那么您可能正在运行不允许 8080 通过的防火墙。 Changing firewall configuration requires root access.更改防火墙配置需要 root 访问权限。

The problem for me was that my Tomcat started listening to IPv6 ONLY.我的问题是我的 Tomcat 开始只监听 IPv6。 Putting it here in case somebody else finds out the same thing.把它放在这里以防其他人发现同样的事情。

I was able to get proper responses with我能够得到适当的回应

curl -g -6 "http://[::1]:8080/"

But not with localhost.但不是本地主机。 To fix this, I removed address attribute from conf/server.xml:为了解决这个问题,我从 conf/server.xml 中删除了address属性:

<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" URIEncoding="UTF-8" />
           address="0.0.0.0" />

and restarted and it bound to IPv4 again.并重新启动,它再次绑定到 IPv4。 I know it should be other way around, but this was what fixed it for me.我知道它应该是相反的,但这就是为我修复它的原因。 OS was Ubuntu.操作系统是 Ubuntu。

Try to list out using following command on linux terminal TCP IP and port reference to the application like "java" as below.尝试在 linux 终端 TCP IP 和端口引用上使用以下命令列出应用程序,如“java”,如下所示。

[root@h5 ~]# netstat -ltnp | grep java -i --colour 
tcp        0      0 10.15.11.20:9990    0.0.0.0:*               LISTEN      1626/java           
tcp        0      0 10.15.11.20:8080    0.0.0.0:*               LISTEN      1626/java           
tcp        0      0 10.15.11.20:8443    0.0.0.0:*               LISTEN      1626/java 
   

Further first you need to check the open ports at the firewall.首先,您需要检查防火墙的开放端口。

firewall-cmd --list-ports

If it is turn on and port is not there please allow the relevant port 8080 as below.如果它是打开的并且端口不存在,请允许相关的端口 8080 如下。

firewall-cmd --permanent --zone=public --add-port=8080
firewall-cmd --reload

On CentOs I had to open the firewall manually在 CentOs 上我必须手动打开防火墙

sudo firewall-cmd --zone=public --add-port=7999/tcp --permanent
sudo firewall-cmd --reload

Not sure how, but if Docker was running a container on the same port, it would automatically open the firewall and so was throwing me off不知道如何,但如果 Docker 在同一个端口上运行一个容器,它会自动打开防火墙,所以让我失望

In case of war deployment if there is error in war file, tomcat may not be able to extract the war file.在war部署的情况下,如果war文件有错误,tomcat可能无法解压war文件。 Make sure a folder having same name as war file is created in tomcat//libexec/webapps otherwise localhost:8080 will stuck.确保在 tomcat//libexec/webapps 中创建了一个与 war 文件同名的文件夹,否则 localhost:8080 会卡住。

Tomcat may be too slow to start if one of the deployed applications is too slow to initialize.如果部署的应用程序之一太慢而无法初始化,Tomcat 可能会太慢而无法启动。 You can tell this is the case when you've started Tomcat, yet the browser says the server isn't responding, even though you can see that the port is listening (by connecting with telnet).当您启动 Tomcat 时,您可以看出这是这种情况,但浏览器说服务器没有响应,即使您可以看到端口正在侦听(通过使用 telnet 连接)。 Also note that your CPU usage may be too high.另请注意,您的 CPU 使用率可能过高。 In my case, it was because I had enabled TRACE mode on the logger.就我而言,这是因为我在记录器上启用了 TRACE 模式。

您可以尝试通过运行来确认服务器的状态:

 lsof -i :8080

Close the IDE.关闭 IDE。 Restart the process java.exe if you are on a windows system.如果您使用的是 Windows 系统,请重新启动进程 java.exe。 And fire up the IDE after that.然后启动IDE。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM