84

So got this project which worked just fine before the weekend (have other problems, but at least Tomcat launched). Now when I try to launch the Tomcat server it immediately gives the following error:

Server Tomcat v7.0 Server at localhost failed to start.

However, I can start Tomcat just fine via Terminal, and this problem is occurring in Eclipse (Eclipse Java EE IDE for Web Developers. Version: Juno Service Release 1 Build id: 20121004-1855)

I scoured several forums trying to find a solution but to no avail.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Marvin Effing
  • 2,693
  • 3
  • 20
  • 35
  • post the full stacktrace error? – Ami Nov 06 '12 at 04:11
  • @ILLA there is none. Just that. Which is the strangest thing about it... – Marvin Effing Nov 06 '12 at 04:12
  • Nice question, The strangest error I had ever encounter. Mime was happened in Fedora 17. The eclipse is download from Fedora repo. – huahsin68 Mar 19 '13 at 14:11
  • Solved by deleting specific folder in Servers folder, removing Server in Eclipse, and then creating new Server in Eclipse (Server tab) – CodyBugstein Aug 29 '14 at 03:30
  • 5
    This is one of the common problem a developer face, from my experience I can advice that most of the time error is because of the web.xml file . Try to remove few newly created servlet and servlet-mapping tags . – Prateek Joshi Nov 09 '15 at 14:42
  • @PrateekJoshi, Thanks! It turns out that this occurs when the xml config has some errors – Swastik Padhi Sep 08 '16 at 07:17

35 Answers35

114
  1. Open the Servers Tab from Windows → Show View → Servers menu

  2. Right click on the server and delete it

  3. Create a new server by going New → Server on Server Tab

  4. Click on "Configure runtime environments…" link

  5. Select the Apache Tomcat v7.0 server and remove it. This will remove the Tomcat server configuration. This is where many people do mistake – they remove the server but do not remove the Runtime environment.

  6. Click on OK and exit the screen above now.

  7. From the screen below, choose Apache Tomcat v7.0 server and click on next button.

  8. Browse to Tomcat Installation Directory

  9. Click on Next and choose which project you would like to deploy:

  10. Click on Finish after Adding your project

  11. Now launch your server. This will fix your Server timeout or any issues with old server configuration. This solution can also be used to fix “port update not being taking place” issues.

Mike
  • 14,010
  • 29
  • 101
  • 161
chandrsekar.L.S.
  • 1,263
  • 1
  • 8
  • 3
  • 12
    unfortunately this does not solve anything ... Eclipse Kepler, Windows 7 32 bit, Tomcat 7 ... I am still looking for the real solution – Miklos Krivan Mar 15 '14 at 12:27
  • 2
    I removed the tomcat configuration from the eclipse and add the server again. Worked for me. Eclipse Juno. – user2771655 May 02 '14 at 03:32
  • 1
    Thnks a lot dude! SO removing the Runtime Environment did the Tric? – Rahal Kanishka Mar 15 '16 at 14:37
  • 1
    as said by @MiklosKrivan - this does not work for me too, but however I am curious to know why & how the hell it works for other and in turn interested to know why it does not for me. – nightfury May 29 '18 at 16:39
60

To resolve this issue, you have to delete the .snap file located in the directory:

<workspace-directory>\.metadata\.plugins\org.eclipse.core.resources

After deleting this file, you could start Eclipse with no problem.

mmvsbg
  • 3,570
  • 17
  • 52
  • 73
Ami
  • 4,241
  • 6
  • 41
  • 75
  • thanks this works. now back to the main question: annnnd, yes it worked! okidokie thanks bro – Marvin Effing Nov 06 '12 at 04:38
  • 37
    please where is this file? i have no such file – William Kinaan Mar 07 '13 at 12:03
  • 19
    There is not such file inside that directory. – MrYo Apr 11 '13 at 10:49
  • 34
    @MarvinEffing I delete this file, but it didn't help me! – Lrrr Oct 23 '13 at 09:21
  • thats worked! but when i restarted eclipse my project had been hide.. again i imported project to same workspace.. – Mohsin AR Jan 31 '14 at 23:13
  • @Marvin Effing It works but I wonder why this would happen since I can start the Tomcat from Eclipse before. Thx – GilbertLee Apr 04 '14 at 09:45
  • I try above solution but now my eclipse is not able to open. Finally I undo delete above directory and then my eclipse is able to open. – ParikshitSinghTomar Oct 16 '14 at 17:35
  • I tried this one but even i am getting error : Removing obsolete files from server... Could not clean server of obsolete files: null java.lang.NullPointerException.How to fix this? – MMMMS Feb 18 '15 at 11:24
  • 1
    This worked for me, but can you explain **why** it worked? What is this file? Why does it cause the error? Also, to the people who can't see the file: try restarting eclipse, that's what I had to do. – Kevin Workman Jan 05 '16 at 22:49
  • In addition to clearing temporary files, it's also important to make sure multiple servlet classes aren't listening at the same URL, as this will also cause the "failed to start" error. – alttag Mar 02 '16 at 22:26
  • 1
    After I deleted the snap file (it was 0.snap), I went to eclipse, right click on the server and selected Clean. Then Start the server and it will work. – sunlover3 Apr 09 '16 at 09:46
  • This unfortunately did not help for me. – Jakob Alexander Eichler May 06 '16 at 18:59
  • the solution totally did not work for me...How can this be an acceptable solution.. – Dila Gurung Aug 05 '16 at 07:28
  • There is a big possibility that the problem is with the web.xml – ImZyzzBrah Nov 13 '18 at 12:40
  • Here's the easiest way worked for me to resolve the issue and others also need to try first the same method before navigating complicated ways. While the project is open in Eclipse, just click "Project" tab from the menu bar at the top and then click "Clean" from the lists. With that, the project got cleaned and fixed the issue in my case. I would suggest anyone to try this simplest method first unless your issue has to do with port and xml configuration issues. – Tes May 09 '20 at 23:51
38

To resolve this issue you have to delete tmp folder in the following directory

<workspace-directory>\.metadata\.plugins\org.eclipse.wst.server.core

If there is any problem on deleting this folder then restart your eclipse then again delete that folder.

jaideep
  • 1,631
  • 17
  • 19
  • I dont see the name of folder folder.where is it? i am using ubuntu 12.04 – MMMMS Feb 18 '15 at 07:54
  • @MMMMS, the hidden files and directories are preceded by dot. Under most *nix systems, you can search such files and directories with ls -a – FRK Aug 29 '17 at 17:56
23

In my case, the problem was in the xml code somehow.

My web.xml file looked like this:

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
    <display-name>Archetype Created Web Application</display-name>

    <servlet>
        <servlet-name>index</servlet-name>
        <jsp-file>index.jsp</jsp-file>
    </servlet>

    <servlet-mapping>
        <servlet-name>index</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>

but I changed it to look like

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
    <display-name>Archetype Created Web Application</display-name>

</web-app>

and now the server loads up properly. Strange.

CodyBugstein
  • 21,984
  • 61
  • 207
  • 363
17

Server Tomcat v7.0 Server at localhost failed to start.

This error resolve following three case

1.Clean project & server

Or

2.Remove .snap file from this directory

<workspace-directory>\.metadata\.plugins\org.eclipse.core.resources

Or

3.Remove temp file from this directory

<workspace-directory>\.metadata\.plugins\org.eclipse.wst.server.core
13

i encountered this problem ,becaues i define servlet mapping in servlet class and web.xml.

You must to be careful to check whether you have defined servlet mapping in your servlet class and web.xml

1)delete @WebServlet("...")

@WebServlet("/Login")
public class Login extends HttpServlet {
}

OR

2)delete <servlet></servlet> <servlet-mapping></servlet-mapping>

<servlet>
    <servlet-name>ServletLogin</servlet-name>
    <servlet-class>Login</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>ServletLogin</servlet-name>
    <url-pattern>/login</url-pattern>
</servlet-mapping>

Reason:

I use apache tomcat 7.0 which supports servlet 3.0.

With Java EE annotations, the standard web.xml deployment descriptor is

optional. According to the servlet 3.0 specification at

http://jcp.org/en/jsr/detail?id=315

C0de8ug
  • 186
  • 1
  • 8
13

None of the answers mentioned above worked for me. I am using Tomcat 9 in my Eclipse IDE. Hence I tried the following steps on my Eclipse Neon.

Step #1: Click on Servers tab to see your server. In my case, it looks like the following:

enter image description here

Step #2: Right click on the server, select Properties, you will see the following window. Click on Switch Location, it will change the location to the one shown in the image below from the default one.Click on Apply and then OK to close the window.

enter image description here

Step #3 Double click on the Tomcat Server which will open the Overview option as shown in the image below. The Server Locations part was active for me when I did (it's shown inactive in the image because I already did that at my end and I have my server running) that and I selected the second radio button option which is Use Tomcat installation (takes control of Tomcat installation). I then closed this option , saved the changes when prompted and started my server. It started working fine.

enter image description here

John
  • 1,210
  • 5
  • 23
  • 51
8

In my case, the problem was in the web.xml file, where i forgot to precede the url-pattern with a "/" (e.g. /login.do).

What solved my problem was, as mentioned above by @Ajak6, by adding the servlet API as an external JAR library for the project.

However, I found a better way, by adding Tomcat to the target runtime as follow;

1) project > properties

2) on the side menu select "Targeted runtimes"

3) select Tomcat (click apply)

4) click ok

Emad Abdelhamid
  • 305
  • 5
  • 16
  • In my case, it worked fine with Annotations, but when I added the servlet configs in web.xml -- I forgot to put that /, and I got this problem. Fortunately, this was I quick fix. Thanks Emad! – ppalancica Jun 26 '16 at 17:25
7

Creating a new workspace can also resolve this issue..

Vibhor Bhardwaj
  • 3,071
  • 5
  • 28
  • 49
  • 33
    that would be running away from the issue not resolving. – Yauraw Gadav Sep 02 '13 at 23:49
  • 1
    Actually won't, because it's probably something in the project mapping. – George Mar 01 '16 at 17:18
  • If this is your case, you can be having trouble with the workspace directory permissions. In my case the problem was that server checks some file of the workspace directory and one time I opened by mistake Eclipse with sudo and some files were created with only-admin permissions. The solution was to change all workspace directory permissions with chmod to allow my user check those files. – José Manuel Blasco Jul 07 '21 at 10:13
6

I had the same problem in my tomcat server but when i check deeply i found that i add a new tag in my web.xml file and the server doesn't accept it so check your file to if any update happened then restart your tomcat and will be good .

REDA
  • 383
  • 1
  • 4
  • 8
  • 1
    I had confused between and in my web.xml and got this error. Thanks! your solution worked for me. – Aafreen Sheikh Apr 28 '14 at 11:18
  • 1
    ok ,good for you it worked for me too and of course if you get confused between them the server won't start because defined to container and Mapping with servlet and url for the http requests. – REDA Apr 29 '14 at 10:34
  • omg, can't believe. I had the same issue. Thanks man, I can't tell you how much I am thankful to you. – Rakesh Yadav Jan 28 '17 at 17:16
6

open your web.xml file. (if you don't know where is it, then just google it.) it is like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
.
.
.
.
</web-app>

just below the <?xml version="1.0" encoding="UTF-8"?> line, add a tag <element> and close it in the very bottom with </element> tag. Done.

codingbruh
  • 2,263
  • 1
  • 13
  • 14
4

Everything was working fine one second and then my server started giving me this error. I went through all the answers mentioned here and what worked for me was this simple solution:

Deleting the server and then configuring a new one

If you're sure that you didn't change anything and the error just popped up, DO NOT start deleting .snap files or other temp files. Doing that will only cause more problems. And if the error occurred because of some changes made by you, this error is definitely going to be because of some errors in web.xml file.

P.S. Changing the workspace will do you absolutely no good, because if the problem is in your project, then it'll still occur in the new work space when you'll import the project!

user2851347
  • 91
  • 1
  • 12
2

Try to delete the existing tomcat server in the server console ,if you don't have the console then you can go to "Show view ->server" then delete the server by right clicking on it. Add new server this will surely help you.

2

In my case I did deploy my tomcat folder (the one having all files in it) into an other place.

Then when I started eclipse and tried to run my project with jsp's and servlets I got this same error.

I tried all the answers here but it still didn't change anything. The solution for me was to put all tomcat JAR files into the project librarie like so:

  1. Go to Eclipse
  2. Right click on the project you work on > Build Path > Configure Build Path... > Libraries > Add External JARs
  3. select all JAR files from the Tomcat/bin and Tomcat/lib
  4. Press "Ok"

Now you should find them in the Libraries folder of your project and then it should work.

user229044
  • 232,980
  • 40
  • 330
  • 338
Iwan Cuche
  • 45
  • 5
2

I had the same problem, and non of the answers here helped my case. So after several hours of searching I found the solution for me and I hope it'll help somebody else.

This is a solution for anyone who gets the "Server Tomcat v7.0 Server at localhost failed to start." error after configuring the tomcat server in eclipse and trying to run a project on it.

After configuring the tomcat server in eclipse you need to copy the "WEB-INF" directory from your tomcat. C:\ ... %TOMCAT_HOME%\webapps\ROOT and their you will find the "WEB-INF" just copy and paste it in your WebContent folder in you eclipse project (overwrite the web.xml file).

Hope this helps.

ChicoDelaBarrio
  • 171
  • 2
  • 11
2

in my case the error was it was not able to find servlet-api.jar. Don't know why suddenly it started giving error for that. Because previously it was running without any issue. After giving the servlet-api.jar in the build path option the server started successfully.

Ajak6
  • 727
  • 5
  • 17
  • after trying all the above, this actually guided me through. **IT WAS UNAVAILABILITY OF SOME DEPENDENCIES** – Young Emil Apr 04 '17 at 09:12
2

1-Go to your workspace directory » .metadata » .plugins » org.eclipse.wst.server.core folder.

2- Delete the tmp folder.

3- Restart your Eclipse IDE

1

In my eclipse workspace, it was resolved by doing the below steps. Window --> Preferences --> Network Connections --> Change 'Active Provider' to 'Direct', instead of 'Native'. You may try it.

Pijush
  • 417
  • 5
  • 3
1

I was facing similar problem this weekend. Tried all the above mentioned tricks, but none of them worked of me. (Working in Eclipse LUNA)

Then i analysed that just before creating a particular servlet, i was running Apache Tomcat v7.0 successfully. Which was "RefreshServlet" as shown below :

RefreshServlet.java

So that practicing servlets to understand the "AutoRefresh" functioning. When i remove this servlet from my application, it works fine, but when i try to add and run this servlet, it gives the same error "Apache Tomcat v7.0 failed to start"

Don't know why, but only removing this servlet works fine for me to run the rest of my application.

So, the bottom line suggestion from me would be that if not any other trick is working, then try removing any latest servlet or any class you just created before getting this error and it may work fine for you too for the rest of the application.

Any further explanation would be appreciated. Thanks

  • 1
    It's possible you have multiple servlets listening at the same URL, which will cause Tomcat to fail to start. – alttag Mar 02 '16 at 22:23
1

Check your web descriptor (web.xml) or on your servlets (Where you annotate, check sor something like '@WebServlet("/servlet_name")') for any duplicates.If any, remove them.

Mwangi Thiga
  • 1,339
  • 18
  • 22
1

I fixed this problem by right clicking on tomcat server in Server tab and click "Clean Tomcat Work Directory"

Hafiz Hamza
  • 311
  • 3
  • 16
0

You can right click on apache-tomcat, choose properties, click Restore Default.

pkpk
  • 1
0

In my case the problem was caused by a syntax error in the arguments being passed. I had a space between the key & value when using '-D'

i.e.

-DMyArg= MyValue

instead of

-DMyArg=MyValue
Kevin
  • 11,521
  • 22
  • 81
  • 103
0

double click on apache server in eclipse server tab. now change tomacat admin port to 8010, http port change to 8082 and Ajp port change to 8011.

sudeep biswas
  • 93
  • 2
  • 7
0

If all given answer are not working for you then just change your current workspace.

file-> switch worksspace

It would be solve your problem.

Umesh
  • 207
  • 1
  • 6
0

In my case, the issue was with another instance of Tomcat was running. I stopped it from services and the issue got resolved

Vishnu
  • 1,516
  • 1
  • 10
  • 15
0

After trying all above mentioned steps , issue was not resolved.

Finally it resolved with below steps.

1- Check .log file inside your work space directory. Issue with Java Version

"Caused by: java.io.IOException: Cannot run program "C:\jdk1.7.0_45\bin\java": CreateProcess error=193, %1 is not a valid Win32 application at java.lang.ProcessBuilder.start(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at org.eclipse.debug.core.DebugPlugin.exec(DebugPlugin.java:869) ... 80 more

Caused by: java.io.IOException: CreateProcess error=193, %1 is not a valid Win32 application at java.lang.ProcessImpl.create(Native Method) at java.lang.ProcessImpl.(Unknown Source) at java.lang.ProcessImpl.start(Unknown Source)"

I have installed correct OS compatible JDK and issue was resolved. PS: I have explicitly set JDK path through eclipse (Window->preference->installed JRE )but after setting correct JDK path ,it work fine for me.

Saurabh Gupta
  • 129
  • 1
  • 2
  • 5
0

1st check in your Web.xml that there are multiple < servlet mapping > tags with different names If so Delete the unwanted ones and Run.. This should work fine

OR

To resolve this issue, you have to delete the .snap file located in the directory .

Goto your Workspace of Eclipse which you are UsingPath --> workspace.metadata.plugins\org.eclipse.core.resources\snapfile

Delete the snap file.

After deleting this file, Delete the Tomcat Server Then also Delete the Server runtime which is selected as Apache tomcat. Then Add Server again and Goto Project-->Properties-->Project Facets-->Right side you will find Details and Runtimes Tabs. Click Runtimes and Check the box of Apache which is already there(If not exist add it)

Change port numbers and Run it.

0

try removing all your project's dependencies from maven local repository(.m2).

Path : C:\Users\user_name\.m2\repository

close eclipse and open again it'll automatically download all the dependencies.

Isuru
  • 129
  • 7
0

I solved my problem by closing all other projects in eclipse simply.

azhar baloch
  • 527
  • 6
  • 11
0

enter image description here

Consider cleaning your poject before running the servelet. This will delete all the corrupted files.

Aakash K T
  • 47
  • 8
0

The problem could be annotations in your servlet(s), see if you are using annotations for URL patterns for your servlets.

Try to change the project facet (Dynamic web project ) version to 2.5 and define all your servlet entries in web.xml this should solve the issue.

you can change project facet version in eclipse by changing it in project properties-->search for "facet" in the search box change the Dynamic web project facet version to 2.5

Ankur
  • 29
  • 1
  • 10
0

Create New Project and Import all files to the new project.it worked for me....

Optimaz Prime
  • 857
  • 10
  • 11
0

In my case, removing servlet tags from web.xml and adding missing libraries in tomcat lib folder solved the issue.

flashleo
  • 45
  • 6
0

If all the above answers don't work, a possible solution might be -

Check if there are multiple <Context> for the same resource in the server.xml of your project. If yes, remove one of the duplicates and try again.

Saad Patel
  • 49
  • 7