Tomcat中的地址绑定异常

时间:2018-08-03 06:59:13

标签: tomcat java-8

自1年以来,我们一直在Apache Tomcat 8.0.36服务器中运行Java 8 Web应用程序。 从过去的几天开始,有时我们重新启动Tomcat服务器时,该应用程序无法正常工作。日志显示Https端口的地址绑定异常。 我尝试使用cmd中的以下命令检查与端口关联的进程:

netstat -aon | findstr [端口]

,但未显示与端口相关的任何进程。

我尝试从任务管理器中关闭tomcat进程,还尝试执行tomact shutdown.bat,然后再次启动tomcat,但没有任何帮助。

如果在部署了应用程序的系统上重新启动系统,问题可以解决,但我们无法随时重新启动系统

请帮助解决可能出现的问题以及可以检查的其他内容?

以下是tomcat错误日志中的错误:

03-Aug-2018 11:42:32.008 INFO [main] org.apache.coyote.AbstractProtocol.init 
Initializing ProtocolHandler ["http-nio-443"]
03-Aug-2018 11:42:32.008 SEVERE [main] 
org.apache.coyote.AbstractProtocol.init Failed to initialize end point 
associated with ProtocolHandler ["http-nio-443"]
java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:351)
at 
org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:748)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:459)
at 
org.apache.coyote.http11.AbstractHttp11JsseProtocol.init(AbstractHttp11Jss
eProtocol.java:120)
at org.apache.catalina.connector.Connector.initInternal(Connector.java:960)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardService.initInternal
(StandardService.java:568)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at  org.apache.catalina.core.StandardServer.initInternal
 (StandardServer.java:869)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.startup.Catalina.load(Catalina.java:580)
at org.apache.catalina.startup.Catalina.load(Catalina.java:603)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:310)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:484)

03-Aug-2018 11:42:32.008 SEVERE [main] 
 org.apache.catalina.core.StandardService.initInternal Failed to initialize 
 connector [Connector[HTTP/1.1-443]]
 org.apache.catalina.LifecycleException: Failed to initialize component 
[Connector[HTTP/1.1-443]]
 at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:106)
 at org.apache.catalina.core.StandardService.initInternal
(StandardService.java:568)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardServer.initInternal
(StandardServer.java:869)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.startup.Catalina.load(Catalina.java:580)
at org.apache.catalina.startup.Catalina.load(Catalina.java:603)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:310)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:484)
Caused by: org.apache.catalina.LifecycleException: Protocol handler 
initialization failed
at org.apache.catalina.connector.Connector.initInternal(Connector.java:962)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
... 12 more
Caused by: java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:351)
at 
org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:748)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:459)
at org.apache.coyote.http11.AbstractHttp11JsseProtocol.init
(AbstractHttp11JsseProtocol.java:120)
 at org.apache.catalina.connector.Connector.initInternal(Connector.java:960)
 ... 13 more03-Aug-2018 11:42:32.008 INFO [main] 
org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http- 
nio-443"]
03-Aug-2018 11:42:32.008 SEVERE [main] 
org.apache.coyote.AbstractProtocol.init 
Failed to initialize end point associated with ProtocolHandler ["http-nio- 
443"]
java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:351)
at org.apache.tomcat.util.net.AbstractEndpoint.init
(AbstractEndpoint.java:748)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:459)
at org.apache.coyote.http11.AbstractHttp11JsseProtocol.init
(AbstractHttp11JsseProto col.java:120)
at org.apache.catalina.connector.Connector.initInternal(Connector.java:960)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardService.initInternal
(StandardService.java:568)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardServer.initInternal
(StandardServer.java:869)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.startup.Catalina.load(Catalina.java:580)
at org.apache.catalina.startup.Catalina.load(Catalina.java:603)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:310)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:484)

03-Aug-2018 11:42:32.008 SEVERE [main] 
org.apache.catalina.core.StandardService.initInternal Failed to initialize 
connector [Connector[HTTP/1.1-443]]
org.apache.catalina.LifecycleException: Failed to initialize component 
[Connector[HTTP/1.1-443]]
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:106)
at org.apache.catalina.core.StandardService.initInternal
(StandardService.java:568)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardServer.initInternal
(StandardServer.java:869)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.startup.Catalina.load(Catalina.java:580)
at org.apache.catalina.startup.Catalina.load(Catalina.java:603)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:310)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:484)
Caused by: org.apache.catalina.LifecycleException: Protocol handler 
initialization failed
at org.apache.catalina.connector.Connector.initInternal(Connector.java:962)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
... 12 more
Caused by: java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:351)
at org.apache.tomcat.util.net.AbstractEndpoint.init
(AbstractEndpoint.java:748)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:459)
at org.apache.coyote.http11.AbstractHttp11JsseProtocol.init
(AbstractHttp11JsseProtocol.java:120)
at org.apache.catalina.connector.Connector.initInternal(Connector.java:960)
... 13 more

1 个答案:

答案 0 :(得分:6)

请参阅下面的更新。我们认为我们已经找到了根本原因和解决方案

我们遇到了同样的问题:一个运行了将近一年没有问题的tomcat服务在停止然后重新启动后无法绑定到它使用的端口。

我们通常每天晚上定期停止并重新启动我们的tomcat服务,该服务过去一直工作正常。该问题首先发生在7月24日,因此在我和我们的IT部门进行了大量研究之后,我怀疑7月24日之前不久发生的IT基础架构中的某种变化会导致此问题。

我们的服务器是64位Windows Server 2012 R2,但是我们的IT环境是虚拟化的,运行在vSphere Host Version 6上。您的tomcat在什么服务器/基础结构上运行?它是虚拟系统还是在物理服务器上运行?

我认为问题出在Windows的最新安装补丁中 (KB4338815和/或KB4339093)或带有某些Hypervisor更新。但是我们的IT部门仍在研究中。

目前,作为解决方法,我们在关闭服务时重新启动服务器 并每晚定期重新启动。但是由于问题不可靠而发生 每次关闭/重新启动时,我们仅在确实必要时重新启动服务器。为此,我们使用了已在server.xml中实现并配置的侦听器,该侦听器在tomcat服务启动后立即扫描stderr.log。如果检测到绑定异常发生,它将重新启动服务器(tomcat服务已自动安装)。如果您找到了造成此问题的原因,请在我或我们的IT部门发现的情况下,将其张贴在这里。

8月7日更新: 我们认为已经找到了根本原因。显然,七月份的Windows每月质量汇总会引入此问题。在我们的案例(Windows Server 2012 R2,64位)中,有问题的更新为KB4338815(请参见https://support.microsoft.com/en-us/help/4338815/windows-81-update-kb4338815)。

如果您在Internet上进行了快速研究,则该问题(也影响Windows IIS Web服务器和MS SQL Server)通常被描述为与KB4338818有关(请参见https://support.microsoft.com/en-us/help/4338818/windows-7-update-kb4338818),但这是针对同一更新的Windows Server 2008 R2和Windows7。

Microsoft已经意识到此问题,并在上​​述文章的“此更新中的已知问题”部分的KB4338815和KB4338818文档中对其进行了描述。 Microsoft指出,KB4338831(对于Windows Server 2012 R2,Windows 8.1)和KB4338821(对于Windows Server 2008 R2,Windows 7)已经解决了问题。

在我们的案例中,我们安装了修补程序KB4345424(请参阅https://support.microsoft.com/en-us/help/4345424/improvements-and-fixes-windows-8-1-and-server-2012-r2),该修补程序也可以从Microsoft获得,该修补程序解决了该错误,据我们所知,该问题不再存在。