tomcat显示启动成功,访问不了

问题阐述

解压tomcat成功之后,发现访问不了。

问题分析

1.开通了防火墙,但是没有放开8080端口号

查看防火墙状态:firewall-cmd --state
显示running表示防火墙是开启状态
执行放开8080端口的命令:firewall-cmd --zone=public --add-port=8080/tcp --permanent

2.服务器没有添加规则,例如阿里云,腾讯云服务器都需要添加端口号的规则

3.tomcat显示启动成功,但是启动日志报错,报错信息如下:

27-Apr-2022 20:11:52.136 SEVERE [main] org.apache.catalina.util.LifecycleBase.handleSubClassException Failed to initialize component [Connector[HTTP/1.1-8080]]
	org.apache.catalina.LifecycleException: Protocol handler initialization failed
		at org.apache.catalina.connector.Connector.initInternal(Connector.java:1049)
		at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
		at org.apache.catalina.core.StandardService.initInternal(StandardService.java:556)
		at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
		at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:1042)
		at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
		at org.apache.catalina.startup.Catalina.load(Catalina.java:724)
		at org.apache.catalina.startup.Catalina.load(Catalina.java:746)
		at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
		at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
		at java.lang.reflect.Method.invoke(Method.java:498)
		at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:305)
		at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475)
	Caused by: java.net.BindException: Address already in use
		at sun.nio.ch.Net.bind0(Native Method)
		at sun.nio.ch.Net.bind(Net.java:461)
		at sun.nio.ch.Net.bind(Net.java:453)
		at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:222)
		at org.apache.tomcat.util.net.NioEndpoint.initServerSocket(NioEndpoint.java:274)
		at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:229)
		at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1227)
		at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:1240)
		at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:603)
		at org.apache.coyote.http11.AbstractHttp11Protocol.init(AbstractHttp11Protocol.java:80)
		at org.apache.catalina.connector.Connector.initInternal(Connector.java:1046)
		... 13 more

显示端口号被占用,可以使用命令netstat -lnpt命令查看8080端口是否被占用。然后kill掉这个进程,重试即可。
或者修改tomcat的端口号,修改命令为:sed -i 's/Connector port="8080"/Connector port="80"/' /usr/local/Tomcat8.5/conf/server.xml
我这块kill掉8080端口的进程之后,启动tomcat,查看tomcat的启动日志(启动日志的命令,在tomcat的logs目录下执行:tail -200 catalina.out)。发现如下报错:Could not contact [localhost:8005] (base port [8005] and offset [0]).,在网上搜了搜,执行了个命令:killall java杀死所有java进程之后再重启启动tomcat即可。

你可能感兴趣的:(报错,tomcat,tomcat)