Tuesday, July 19, 2016

java.net.BindException


 

Tomcat: java.net.BindException: Address already in use: bind

Recently we started getting a problem while restarting the tomcat.

java.net.BindException: Address already in use: bind
 at sun.nio.ch.Net.bind0(Native Method)
 at sun.nio.ch.Net.bind(Net.java:444)
 at sun.nio.ch.Net.bind(Net.java:436)
 at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
 at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
 at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:340)
 at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:742)
 at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:458)
 at org.apache.coyote.http11.AbstractHttp11JsseProtocol.init(AbstractHttp11JsseProtocol.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:851)
 at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
 at org.apache.catalina.startup.Catalina.load(Catalina.java:576)
 at org.apache.catalina.startup.Catalina.load(Catalina.java:599)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:310)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:484)
7 19, 2016 5:39:55 午後 org.apache.catalina.core.StandardService initInternal
重大: Failed to initialize connector [Connector[HTTP/1.1-8080]]
org.apache.catalina.LifecycleException: Failed to initialize component [Connector[HTTP/1.1-8080]]
 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:851)
 at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
 at org.apache.catalina.startup.Catalina.load(Catalina.java:576)
 at org.apache.catalina.startup.Catalina.load(Catalina.java:599)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 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: プロトコルハンドラの初期化に失敗しました
 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(Net.java:444)
 at sun.nio.ch.Net.bind(Net.java:436)
 at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
 at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
 at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:340)
 at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:742)
 at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:458)
 at org.apache.coyote.http11.AbstractHttp11JsseProtocol.init(AbstractHttp11JsseProtocol.java:120)
 at org.apache.catalina.connector.Connector.initInternal(Connector.java:960)
 ... 13 more

1. First you need to check which two processes running on same port number 8080 (for tomcat). First, identify which Process is binding the desired port by running this from the Command Prompt: You can use 

netstat -o -n -a | findstr 8080
 
to find the PID and check what process it is.
You should get an output like this.

findport

2. Next, use the ProcessID (value in the last column) to kill the process which is holding the same port:

taskkill /F /PID 7844

No comments:

Post a Comment