Sliss
Sliss

Reputation: 33

Tomcat fails to start in Eclipse - java.net.BindException: Address already in use

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?

Upvotes: 2

Views: 18736

Answers (3)

nishanth pgm
nishanth pgm

Reputation: 1

step 1: go to C:\Windows\System32\drivers\etc

step 2:

find hosts file and open it with notepad with admin mode

step 3:

replace local host ip with 127.0.0.1

example

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
    127.0.0.1       localhost
#   ::1             localhost

step 4:

save that file and run server

Upvotes: 0

卢声远 Shengyuan Lu
卢声远 Shengyuan Lu

Reputation: 32014

Change Tomcat port setting:

It seems the Tomcat is already integrated in Eclipse. So there should be a project called "Servers" in your Eclipse, you could find your Tomcat configuration node. Change the port attribute in server.xml. Of course, the plugin provides many ways to integrate with Tomcat, but basic idea is to change server.xml.

Upvotes: -2

Shrikant Thakare
Shrikant Thakare

Reputation: 226

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 ?

Upvotes: 4

Related Questions