简体   繁体   中英

Tomcat not starting (throwing java.net.BindException: )

I have done the following settings to run a Java web project but somehow my Tomcat is not starting from Eclipse:

JAVA_HOME : C:\Program Files\Java\jdk1.6.0_03  
PATH : C:\Program Files\Java\jdk1.6.0_03\bin  
CATALINA_HOME : D:\javaworkspaces\apache-tomcat-7.0.27  

Then as is required, I set up a new server from Eclipse and give the Tomcat installation path.

As advised in some forums, I have added tomcat-juli.jar to the class path.
In spite of all this when I try starting the Tomcat Server, I get the the error as tomcat not staring in 45 sec.

I get the following log message:

Jul 26, 2012 5:49:34 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: C:\Program Files\Java\jre6\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre7/bin/client;C:/Program Files/Java/jre7/bin;C:/Program Files/Java/jre7/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.6.0_03\bin;D:\eclipse-jee-indigo-SR2-win32\eclipse;;.  
Jul 26, 2012 5:49:34 PM org.apache.tomcat.util.digester.SetPropertiesRule   
 begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property         'source' to 'org.eclipse.jst.j2ee.server:JEE_Day01' did not find a matching property.  
Jul 26, 2012 5:49:34 PM org.apache.coyote.AbstractProtocol init  
INFO: Initializing ProtocolHandler ["http-bio-80"]  
Jul 26, 2012 5:49:35 PM org.apache.coyote.AbstractProtocol init  
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]  
Jul 26, 2012 5:49:35 PM org.apache.coyote.AbstractProtocol init  
SEVERE: Failed to initialize end point associated with ProtocolHandler ["ajp-bio-8009"]  
java.net.BindException: Address already in use: JVM_Bind <null>:8009  
at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:393)
at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:566)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:417)
at org.apache.catalina.connector.Connector.initInternal(Connector.java:956)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:814)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.startup.Catalina.load(Catalina.java:624)
at org.apache.catalina.startup.Catalina.load(Catalina.java:649)
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:281)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:449)  
Caused by: java.net.BindException: Address already in use: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(Unknown Source)
at java.net.ServerSocket.bind(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
at org.apache.tomcat.util.net.DefaultServerSocketFactory.createSocket(DefaultServerSocketFactory.java:49)
at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:380)
... 16 more  
Jul 26, 2012 5:49:35 PM org.apache.catalina.core.StandardService initInternal    
    SEVERE: Failed to initialize connector [Connector[AJP/1.3-8009]]
org.apache.catalina.LifecycleException: Failed to initialize component [Connector[AJP/1.3-8009]]  
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:106)  
    at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)  
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:814)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.startup.Catalina.load(Catalina.java:624)
at org.apache.catalina.startup.Catalina.load(Catalina.java:649)
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:281)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:449)  
Caused by: org.apache.catalina.LifecycleException: Protocol handler initialization failed
at org.apache.catalina.connector.Connector.initInternal(Connector.java:958)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
... 12 more

I have referred multiple forums but am badly stuck with the situation. Please guide me.

these lines :

SEVERE: Failed to initialize end point associated with ProtocolHandler ["ajp-bio-8009"]
java.net.BindException: Address already in use: JVM_Bind <null>:8009  

imply that there is already a service running on port 8009. is there a tomcat (with ajp) running already?

if the service running on 8009 is needed you could change the connector configuration in server.xml to something like below :

<Connector port="8089" protocol="AJP/1.3" redirectPort="8443" />

它说端口号8009已经被你操作系统上运行的一些其他进程占用, 尝试搜索该进程并停止它或让你的 tomcat 在不同的(免费)端口上运行

kill the respective (listening) process on this port ie 8009. use

netstat -a -o -n

to look for the PID of the process. It may look something like this TCP [::]:8009 [::]:0 LISTENING 892

use the taskkill command to kill the process. example:

taskkill /F /PID 892

java.net.BindException: Address already in use: JVM_Bind :8009

This means that some other process is already using this port. Could it be another Tomcat instance?

You should not have to change the server.port to fix this problem...

Mac/Unix/Linux Users : If after you restart Tomcat, and this problem still exists, it is probably because Tomcat was shutdown improperly and there are resources still associated with it that are now locked. You can see the PIDs of those resources by running this command:

lsof | grep tomcat

Terminate those processes using:

kill -15 <PID>

This should fix your problem.

Using the kill -15 command to TERM (-15) the process rather than SIGKILL (-9) is preferable. The -15 switch sends the process the signal to begin it's shutdown phases and clean up bounded resources.

尝试 :http://localhost:8089 如果它不起作用(或)试试这个: Set:JRE_HOME : C:\\Program Files\\Java\\jre1.5.0_11(取决于你的 JRE 版本)并添加 C:\\ Program Files\\Java\\jre1.5.0_11(取决于您的 JRE 版本)\\bin 到路径 Eclipse-> 转到 windows 首选项:server->RuntimeEnvironment 删除添加的 Server 和 Referesh 并添加新的 TomcatServer

TIL: Someone else on a server can start IIS on port 80 and not tell anyone.
If you have your tomcat configured for the same port, it will also report this error.
The port on IIS or tomcat will need to be changed.

To modify the port in IIS:
Administrative Tools | Internet Information Services (IIS) Manager
Right Click on Default Web Site | Edit Bindings... Change Port

-OR-

To modify the port in Tomcat:
Open conf\\server.xml and update the port value in tag:

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

Restart Tomcat

Enjoy 2 web services.

Something else is using port 8009.

Either shut down the thing that is using 8009 or change your server.xml to use another port than 8009

This generally happens if the Connector / shutdown port of the tomcat is already being used. First, run the shutdown.bat (Sometimes we miss out that one instance of the tomcat is already running) Next, in the command prompt run

netstat -aon | findstr 0.0:<your port number which is giving bind exception>

To get the PID of the application that is currently using your port. Either kill that application or use some other port which is not listed when you run

netstat -a -o -n

Update all available ports one by one with ports that are free. This must fix the issue

31-Jul-2019 16:28:30.641 SEVERE [main] org.apache.catalina.core.StandardServer.await StandardServer.await: create[localhost: 8005 ]: java.net.BindException: Address already in use: JVM_Bind

Other Tomcat is running on the same port so better to kill using 9 rather than 15

kill -9 PID

This was helpful to me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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