地址Tomcat中的绑定异常 [英] Address Bind exception in Tomcat

查看:115
本文介绍了地址Tomcat中的绑定异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

We are running Java 8 web application in Apache Tomcat 8.0.36 server since 1 year. From past few days sometimes when we restart the Tomcat server , the application is not working. Logs are showing address bind exception for Https port. I tried checking the process associated with the port using below command in cmd:

netstat -aon | findstr [port]

netstat -aon | findstr [port]

但它没有显示与该端口相关的任何进程。

but it is not showing any process associated with the port.

我试过关闭来自任务管理器的tomcat进程并尝试执行tomact shutdown.bat然后再次启动tomcat但没有任何帮助。

I have tried closing tomcat process from task manager and also tried executing tomact shutdown.bat and then started tomcat again but nothing helped.

如果系统重新启动,部署应用程序的问题得到解决但我们无法随时重新启动系统

If the system is restarted where application is deployed the issue gets resolved but we can't restart the system anytime

请帮助解决可能存在的问题以及还有哪些其他问题可以检查?

Please help what could be the issue and what else can be checked?

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

Below is the error in tomcat error log:

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


推荐答案

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

我们遇到了同样的问题:近一年没有问题的tomcat服务不是能够绑定到它停止后使用的端口,然后重新启动。

We have the same problem: A tomcat service that was operating without problems for nearly a year was not able to bind to the port which it used after it was stopped and then restarted.

我们通常每晚定期停止并重新启动我们的tomcat服务,它过去没有工作问题。这个问题最初发生在7月24日,所以在我和我们的IT人员进行了大量研究后,我怀疑7月24日之前不久发生的IT基础架构的某种变化会导致这个问题。

We usually stop and restart our tomcat service regularly every night, and it used to work without problems. The problem first occurred on July 24th, so after a lot of research that I and our IT have done, I suspect that some kind of change in our IT infrastructure that happened shortly before July 24th causes this problem.

我们的服务器是Windows Server 2012 R2,64位,但我们的IT环境已虚拟化,在vSphere主机版本6上运行。您的tomcat运行在哪个服务器/基础架构上?它是虚拟化系统还是在物理服务器上运行?

Our server is a Windows Server 2012 R2, 64 Bit, but our IT environment is virtualized, running on vSphere Host Version 6. On what server/infrastructure is your tomcat operating? Is it a virtualized system or is it running on a physical server?

在我看来,问题出现在最近安装的Windows
补丁中( KB4338815和/或KB4339093)或某些Hypervisor更新。但是我们的IT仍在研究。

In my opinion, the problem came in either with the last installed patches for Windows (KB4338815 and/or KB4339093) or with some Hypervisor updates. But our IT is still researching.

暂时解决这个问题,当我们关闭服务
并每晚定期重启服务器时,我们会重新启动服务器。但是因为每次关闭/重新启动时
都会出现问题不可靠,所以只有在真正需要时才会重启服务器。为此,我们使用我们在server.xml中实现和配置的侦听器,该侦听器在tomcat服务启动后立即扫描stderr.log。如果检测到发生绑定异常,则重新启动服务器(tomcat服务自动安装)。如果您发现此问题的原因,请在此处发布,如果我或我们的IT部门会找到它。

For the moment as a workaround we do a server restart when we shutdown the service and restart it regularly every night. But because the problem does not reliable occur on each and every shutdown/restart, we restart the server only if it is really necessary. To achieve this we use a listener we have implemented and configured in the server.xml that scans the stderr.log just after the tomcat service has started. If it detects, that a Bind Exception occurs it restarts the server (tomcat service is installed as automatic). If you find the cause of this problem, please post it here, as I will, if I or our IT will find it.

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

如果您在互联网上进行快速研究,那么影响Windows IIS Webserver和MS SQL Server的问题大多与KB4338818有关(参见 https://support.microsoft.com/en-us/help/4338818/windows-7-update-kb4338818 )但这与Windows Server 2008 R2和Windows 7的更新类型相同。

If you do a quick research on the internet, the problem, which also affects Windows IIS Webserver and MS SQL Server is mostly described as related to KB4338818 (see https://support.microsoft.com/en-us/help/4338818/windows-7-update-kb4338818) but this is the same kind of update for Windows Server 2008 R2 and Windows 7.

Microsoft已经知道该问题并在KB4338815和KB4338818的文档中对其进行了描述在上述文章的此更新中的已知问题部分中。 Microsoft声明问题已在KB4338831(适用于Windows Server 2012 R2,Windows 8.1)和KB4338821(适用于Windows Server 2008 R2,Windows 7)中解决。

Microsoft is already aware of the problem and describes it in its documentation for KB4338815 and KB4338818 in the "Known issues in this update" section of the mentioned articles. Microsoft states that the problem is resolved in KB4338831 (for Windows Server 2012 R2, Windows 8.1) and KB4338821 (for 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 ),也可提供来自微软,它解决了这个错误,据我们所知,这个问题不再存在。

In our case we installed hot fix KB4345424 (see https://support.microsoft.com/en-us/help/4345424/improvements-and-fixes-windows-8-1-and-server-2012-r2), also available from Microsoft, which addresses this bug and as far as we see, the problem does not exist anymore.

这篇关于地址Tomcat中的绑定异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆