31
votes

I am trying to run Tomcat through Eclipse. This is something that I have done for the past several years. It was working yesterday and now it is not. The error I get is

Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds. If the server requires more time, try increasing the timeout in the server editor.

The Output is

Jul 06, 2012 8:32:26 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: D:\Program Files\Java\jdk1.7.0_05\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;D:\Launch;D:\Program Files\Java\jdk1.7.0_05\bin;%PROGRAMFILES%\Internet Explorer;C:\Program Files (x86)\SMLNJ\bin\;D:\Program Files\TortoiseSVN\bin;C:\ghc\ghc-6.6\bin;D:\Program Files\MySQL\MySQL Server 5.5\bin;%ANT_HOME%/bin;D:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;D:\Program Files\Microsoft SQL Server\100\Tools\Binn\;D:\Program Files\Microsoft SQL Server\100\DTS\Binn\;D:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;D:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;D:\Program Files (86x)\;.
Jul 06, 2012 8:32:26 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jul 06, 2012 8:32:26 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jul 06, 2012 8:32:26 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 468 ms
Jul 06, 2012 8:32:26 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jul 06, 2012 8:32:26 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.28
Jul 06, 2012 8:32:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Program Files\Java\apache-tomcat-7.0.28\webapps\docs
Jul 06, 2012 8:32:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Program Files\Java\apache-tomcat-7.0.28\webapps\examples
Jul 06, 2012 8:32:26 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Jul 06, 2012 8:32:26 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Jul 06, 2012 8:32:26 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@5710ddf9')
Jul 06, 2012 8:32:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Program Files\Java\apache-tomcat-7.0.28\webapps\host-manager
Jul 06, 2012 8:32:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Program Files\Java\apache-tomcat-7.0.28\webapps\manager
Jul 06, 2012 8:32:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Program Files\Java\apache-tomcat-7.0.28\webapps\ROOT
Jul 06, 2012 8:32:26 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jul 06, 2012 8:32:26 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jul 06, 2012 8:32:26 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 504 ms

I have looked around for a solution for several hours now. But I have not had any success and it likely is something simple. I have tried the following:

  1. Delete Serve and remake it in eclipse
  2. Restart computer, eclipse
  3. Reinstall eclipse, tomcat
  4. Start Eclipse with -clean
  5. Start server with no web app
  6. Increasing the timeout

I am able to start tomcat from command line just fine. However, I need to run it through eclipse to debug. I am aware of this SO post and have gone through it and many others to no avail.

Thoughts?

UPDATE: I just realized that the server does start up. However, one of the final functions that eclipse does, fails. How I observed this is by setting the timeout to 10 min. I was able to access the server during that time, however not the debug functionality of eclipse. So Eclipse starts it up, tries do something, that something never completes, Eclipse shuts down Tomcat after that timeout period.

UPDATE: Looking back at what happened around when this problem arose, the computer apparently installed a Java update.

27
Weird, the log seems to indicate that Tomcat started correctly. Did you try to access your webapp on port 8080 despite the error in Eclipse ? It looks like a communication problem between Tomcat and the Eclipse plugin. Do you have a firewall running ? - David Levesque
and yes I did attempt to access it. As explained in the update I can access it before the timeout. - Orlan
ya. I have been using the newest one. I downloaded it off the site today. It is the Juno version. - Orlan
Also have tried using the Helio version. Also both tomcat 6 and tomcat 7 - Orlan
Looks like a duplicate of stackoverflow.com/questions/7390078/… which I answered. Try changing the HTTP port number from the configuration view to something else, for example 8090. - Juha Palomäki

27 Answers

38
votes

A Java update caused the same problem (among others) for me. The update caused Eclipse to use ipv6 when pinging Tomcat and for some reason that doesn't work with my setup.

I fixed it by adding

-Djava.net.preferIPv4Stack=true

To eclipse.ini.

26
votes

I've found that this can happen due to invalid/corrupted/??? breakpoints in your code when you start in "Debug". It is often accompanied by slow start up times.

"Remove All Breakpoints" cleared this up for me.

25
votes

I had a similar problem on my system (Windows 7 pro 64 bit), with Tomcat not starting from any Eclipse version. It turns out that by default Eclipse uses the system network configuration, and if you have configured a proxy that does not resolves localhost the Tomcat startup will hang in Eclipse !

To see if you have this problem go to Window -> Preferences -> General -> Network Connections and see if one of the boxes is checked. I was able to override my proxy configuration by setting Active Provider to Direct (it unchecks all boxes).

10
votes

In my case, I had disabled the HTTP/1.1 Connector on port 8080 in favor of an SSLEnabled (https) HTTP/1.1 Connector on port 8443.

I'm not sure if the Eclipse/Tomcat communication was failing because of the wrong port or the wrong protocol, but when I added the HTTP/1.1 Connector on port 8080 back into my server.xml (in addition to the secure connector on port 8443), Eclipse was able to correctly detect Tomcat's successful startup.

It appears that for Eclipse to recognize that Tomcat has successfully started, Tomcat must be configured to have a non-SSL Connector on port 8080.

6
votes

I was able to fix this issue by doing the following:

  • Right-click on the Tomcat server (under the Eclipse Servers perspective)
  • Select Open - it should open up the xml editor
  • Look for the Timeouts section and increase the value to > 45s

This works with Eclipse Helios / Tomcat 7

5
votes

Well, I tried all these options, I could not get my recent version of STS (Spring Tool Suite 3.7.1.201510041213-RELEASE) to figure out that Tomcat had started.

I tried Tomcat 7.0.64, 8.0.26, 8.0.28. All with the same results. I did get vanilla Tomcat installs to work, so I figured it must a problem with my server.xml (or other file).

So I went through line by line until the server view would stop picking up the started status. Long story short, setting the secure attribute (to any value, like false) on a Connector causes STS to assume that it's another SSL handler.

For example:

<Connector secure="false" executor="conPool" port="8080" redirectPort="8443" protocol="HTTP/1.1" />

Will cause STS to freak out, while:

<Connector executor="conPool" port="8080" redirectPort="8443" protocol="HTTP/1.1" />

Works as intended.

It looks like STS assumes that by merely having the secure attribute, regardless of value, it's an SSL handler. Older versions of STS don't seem to have this problem though. Someone has already filed a very similar bug.

Also note that the server configuration pane shows:

enter image description here

When the server.xml has the secure attribute on a non-SSL connector (and behavior is somewhat wonky), and:

enter image description here

The normal ports listed when it is removed.

4
votes

Ran into same issue here. Tried out all these solutions the others proposed, none of it works for me.

  1. change http 1.1 port to 8090.
  2. add -Djava.net.preferIPv4Stack=true to eclipse.ini (STS.ini in my case).
  3. in Window -> Preferences -> General -> Network Connections, set Active Provider to Direct or Manual.
  4. add 127.0.0.1 localhost to hosts localdns file (C:\Windows\System32\drivers\etc\hosts)

Finally I realized all this happens since I put the tomcat native library in. I removed it and reverted all the changes above, it works now. Anyway, thanks for all your helps which help me connect the issue with the native library.

2
votes

I had messed around with my /etc/hosts file and removed the alias that I had set up in Eclipse. So

  1. Go to Window > Show View > Servers
  2. Double click on the Tomcat v7.0 (that's the version I've got)
  3. In the "Host name:" field check that you have a valid alias - if not sure, use localhost or check /etc/hosts or %systemroot%\system32\drivers\etc\hosts

Extending the timeout only delays the inevitable, it fixes the symptom not the cause.

2
votes

Make sure Tomcat is actually listening to 127.0.0.1 when host name is set to localhost.

When starting the Tomcat server in Eclipse the log displays something like:

10:07:23 INFO  main o.a.c.h.Http11NioProtocol Initializing ProtocolHandler ["http-nio-192.168.2.63-8080"]

Your Tomcat server configuration "Host name" and HTTP/1.1 Port MUST resolve to the displayed IP address & HTTP port (in the given example IP 192.168.2.63 Port 8080)

This fixed it with Eclipse 4.5 (Mars) & Tomcat 8

2
votes

Still facing the same issue after trying all the above solutions. i solved the problem by adding http connector to server.xml. In fact, before fixing the issue, i have only https connector. it seems that eclipse look for tomcat startup by requesting the http url, once removed eclipse can't determine if tomcat is successfully started.

1
votes

I encountered the same problem. I did all this stuff.

  1. Added all the environment variables in system properties.
  2. Window -> Preferences -> General -> Network Connections turned Active Provider to Manual.
  3. Added -Djava.net.preferIPv4Stack=true after -vmargs in eclipse.ini file.
  4. Increased the timeout from 45 sec.
  5. Updated Eclipse.

Hope this helps.. !!!

1
votes

This is a very old post yet no one of these solutions worked for me. I had to do a combination of answers in this post and others to get it working. This is what I did;

  • Add 127.0.0.1 localhost to the host file
  • Add -Djava.net.preferIPv4Stack=true to eclipse.ini file
  • Set Active Provider to Manual in Window > Preferences > General > Network Connections
  • Change Host name in Servers (view) > Overview (pane) to computer's network IP.
  • Disable auto reloading in Server (view) > Module (pane) > Module (list item) > Edit (action button)

References

0
votes

I just noticed that same error here. Eclipse Juno + Apache 7 (7.0.27 and 7.0.29).

The server starts, I can use the application, but stills raising timeout error.

With Eclipse Indigo SR2 it runs correctly. I also noticed that my JAVA_HOME and JRE_HOME variables were deleted (Maybe due some Java Update), so I set the variables again.

0
votes

I solve this trouble adding

127.0.0.1 localhost

to hosts localdns file (C:\Windows\System32\drivers\etc\hosts), seems that this problem is due to a ipv6 on localhost name.

To understand if this is the problem try to ping localhost and see if it is solved ad ipv4 or ipv6.

0
votes

Go to Windows --> Preferences --> NetworkConnections --> there is a drop down having three values:

  1. Direct
  2. Manual
  3. Native

By default it is native, so select the manual and click on Apply.

It will work for Eclipse Juno EE with Tomcat 7.

0
votes

You have to also verify that you are not running a recent version of java jdk ( 1.8 for example ) if it is the case please configure your eclipse to use and older version (1.7 for example ).

0
votes

For those of you trying to start heavy-loaded application, with a lot of INFO level logging to console. Be aware Eclipse console printer can be confused by amount of data to print and hang Eclipse for a long time, while server actually will be started and can be accessed via browser.

This problem happened to me and took me quite a while to figure out what's happening. I'm running Eclipse Mars and Tomcat 7. In my case app was trying to print all singleton bean names to console, about several thousand bean names thus Eclipse was going crazy.

org.springframework.beans.factory.support.DefaultListableBeanFactory#preInstantiateSingletons

    if (this.logger.isInfoEnabled()) {
       this.logger.info("Pre-instantiating singletons in " + this);
    }

Give it a try, put the app logging level=ERROR. Hopefully this will help someone.

0
votes

This can also happen, when you set the host name in the server settings to an invalid value.

0
votes

Looks like Eclipse is verifying Tomcat's running status on :8080.

I had similar problem with Eclipse+Tomcat when I disabled all connectors but one for SSL connections (:8443).

In order to avoid the problem I left both :8080 and :8443 connectors in my server.xml.

0
votes

EDIT:

Make sure your hostname is "localhost", or if you are using a specific IP address, make sure its the CORRECT IP address that your computer has.

I changed my host name from "localhost" to my specific IP address (at the time). This was to solve an issue I encountered while doing mobile app development.

My problem was that my IP address changed. So updated my hostname to my new IP address. (I will revert it to localhost once I'm done with mobile testing).

Just a heads up, sometimes its a simple fix.

0
votes

double-clicking Tomcat v7.0 Server at localhost, change 'Host name' to your IP(IPv4). It used to be 'localhost'

0
votes

I was facing same issue and followed most of the solutions provided but they didn't worked for me.

One of my senior told me the reason for the problem. Previously I created a build for staging environment using mvn clean install -Pstaging, which created a WAR file in the target folder for staging environment. Now whenever I start tomcat it was using the setting from the target to connect to the staging database server and was unable to connect (getting stuck at preparing launch delegate).

Fix: First run mvn clean install in the workspace directory and then in eclipse right click project -> Maven -> Update Project. Now run tomcat.

0
votes

I encountered this problem today,I followed these instructions above but none worked.Finally I delete my tomcat configurations at Servers tab and renew one and at the Server Locations,I choose "Use workspace metadata(does not modify Tomcat installation)",if these options are grey and can not be changed ,try to change the Server Options below and it will work.


PS:This problem seems having no relationship with the proxy settings,as I choose Native option in Network Connections and use a proxy too. When I changed Server Locations Tomcat no long stuck although the preparing launch delegate in progress tab appeared again.

0
votes

Go to Control Panel/ Programs / Programs and Features / installed updates, and uninstall the last Microsoft windows update, restart computer, and it works.

0
votes

Eclipse and tomcat adapter has broken with nio protocol. Change protocol in the port tag in server.xml to protocol="HTTP/1.1".

-1
votes

my problem turned out i had edited the tomcat install server.xml file for ssl on 8443 and no longer on 8080...eclipse pulls that in and would hang on startup... copied original server.xml and created server over again and all good...i have great aim shooting my own feet...

-2
votes

The problem is definitely with your JDK version. If your are running Windows 7 I would consider changing version of your JDK, and your tomcat version.