Tomcat fails to start in Eclipse - java.net.BindException: Address already in use
It seems when you installed Tomcat- it decided to run in service mode and must be running when you start your system. Hence the error when you start the tomcat through eclipse.Using other ports in server.xml maynot solve your problem.My guess is that another instance of tomcat is already running.Can you check in taskmanager of another instance of tomcat is running before you start it from eclipse ? Also can you post result from netstat run ?
Sliss
Updated on June 04, 2022Comments
-
Sliss almost 2 years
I'm new to Tomcat and Eclipse, but have been searching for a solution for days. I've installed Tomcat v7.0 and can start/stop it from the terminal, but I can't get it to work from Eclipse. I'm following the tutorial at http://www.vogella.de/articles/EclipseWTP/article.html#jspservlets, but when I attempt to run my servlet I get the alert: "Server Tomcat v7.0 Server at localhost failed to start" with the console output as:
Feb 18, 2012 7:05:54 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: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java Feb 18, 2012 7:05:54 PM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:de.vogella.wtp.filecounter' did not find a matching property. Feb 18, 2012 7:05:54 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-bio-8080"] Feb 18, 2012 7:05:54 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["ajp-bio-8009"] Feb 18, 2012 7:05:54 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 1046 ms Feb 18, 2012 7:05:54 PM org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina Feb 18, 2012 7:05:54 PM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/7.0.25 Feb 18, 2012 7:05:55 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-bio-8080"] Feb 18, 2012 7:05:55 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["ajp-bio-8009"] Feb 18, 2012 7:05:55 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 654 ms Feb 18, 2012 7:05:55 PM org.apache.catalina.core.StandardServer await SEVERE: StandardServer.await: create[localhost:8005]: java.net.BindException: Address already in use at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383) at java.net.ServerSocket.bind(ServerSocket.java:328) at java.net.ServerSocket.<init>(ServerSocket.java:194) at org.apache.catalina.core.StandardServer.await(StandardServer.java:422) at org.apache.catalina.startup.Catalina.await(Catalina.java:728) at org.apache.catalina.startup.Catalina.start(Catalina.java:674) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450) Feb 18, 2012 7:05:55 PM org.apache.coyote.AbstractProtocol pause INFO: Pausing ProtocolHandler ["http-bio-8080"] Feb 18, 2012 7:05:55 PM org.apache.coyote.AbstractProtocol pause INFO: Pausing ProtocolHandler ["ajp-bio-8009"] Feb 18, 2012 7:05:55 PM org.apache.catalina.core.StandardService stopInternal INFO: Stopping service Catalina Feb 18, 2012 7:05:55 PM org.apache.coyote.AbstractProtocol stop INFO: Stopping ProtocolHandler ["http-bio-8080"] Feb 18, 2012 7:05:55 PM org.apache.coyote.AbstractProtocol stop INFO: Stopping ProtocolHandler ["ajp-bio-8009"] Feb 18, 2012 7:05:55 PM org.apache.coyote.AbstractProtocol destroy INFO: Destroying ProtocolHandler ["http-bio-8080"] Feb 18, 2012 7:05:55 PM org.apache.coyote.AbstractProtocol destroy INFO: Destroying ProtocolHandler ["ajp-bio-8009"]
netstat doesn't show ports 8080, 8005 or 8009 in use before I attempt to run Tomcat, so that doesn't seem to be the problem. Any idea what's going wrong?
-
Sliss about 12 yearsThanks for replying. I think you were right– there may have been another instance running that I didn't recognize. I restarted my system and Eclipse was able to start Tomcat (INFO: Server startup in 484 ms.) Unfortunately, Tomcat itself is now giving me an HTTP 404 error: "The requested resource /de.vogella.wtp.filecounter/servlet/de.vogella.wtp.filecounter.servlets.FileCounter is not available."
-
Sliss about 12 yearsAnother few hours of digging and the help of the thorough tutorial at cse.csusb.edu/turner/java_web_programming/servlets fixed the 404s. I just needed to correct the <url-pattern> line in my xml file.