Krishna
Krishna

Reputation: 119

Server Tomcat v9.0 Server at localhost failed to start

I am using Eclipse Neon and Tomcat server 9.0 and JDK 1.8 It was working well but unfortunately its giving me error 'Server Tomcat v9.0 Server at localhost failed to start.' I tried to change the ports i.e. connection port and other ports too but it did not solve my problem and this error is shown when I start the server or run the web app I am currently working on. Other solution other than change in port because I tried it and it did not resolve my problem?????

Upvotes: 11

Views: 141307

Answers (23)

Kavya
Kavya

Reputation: 1

If you have latest version of eclipse, the problem is with XML file. You need to use Annotations instead of XML file.

@WebServlet("url") ->Use this after imports

Upvotes: 0

Elhem Nouri
Elhem Nouri

Reputation: 91

  1. Go to "Window" menu and select "Preferences".
  2. In the Preferences window, expand the "Java" section and select Installed JREs". Here, you should see a list of JREs that are currently installed on your system. Check if the JRE you are looking for is listed, or you can add it by clicking on the "Add" button and providing the path to the JRE installation directory.

Upvotes: 0

Marvelographer
Marvelographer

Reputation: 23

Try to delete .m2 file in This pc-> C drive-> users -> .m2 then restart eclipse and run the server again

Upvotes: 0

Zahra Vakilifard
Zahra Vakilifard

Reputation: 21

I had the same problem, which was solved when I changed the admin port (right-click on the server inside eclipse and select properties) from a hyphen(default) to another port number. I used another port number for the admin port (not the same as the port number I used for my tomcat)

enter image description here

enter image description here

Hope it helps you Cheers

Upvotes: 2

Niket dubey
Niket dubey

Reputation: 21

Also Verify the Argument should contains "-Dspring.profiles.active="enviroment name"

Upvotes: 0

Nitesh Singh
Nitesh Singh

Reputation: 1

https://www.youtube.com/watch?v=SEO22ifq9qE&ab_channel=%23VhCode

Delete web.xml under WEB-INF of the selected project or correct everything in that file, then try restarting the server.

Upvotes: 0

irfan Quresh
irfan Quresh

Reputation: 59

  1. Delete server by navigating to Window ->Show View -> Server. Right click on server and delete it.
  2. Delete Servers folder from Project Explorer
  3. Delete .metadata of eclipse workspace (CAUTION: You will lose all your workspace settings (e.g.: key bindings, appearance, ...))
  4. Now Restart eclipse and add Apache Tomcat server.

It will work.

Screenshot

Upvotes: 5

Tarun
Tarun

Reputation: 1

Just check your Console. Than search for relevant solution i did everthing, but ended up deleting a mapping error shown in console from web.xml

Upvotes: 0

n0S
n0S

Reputation: 1

Change your redirect port in server.xml to something else and it should work

 <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8900"/>

Upvotes: 0

Syed Aaqib Hussain
Syed Aaqib Hussain

Reputation: 139

If you are using Spring Framework, please check in the WEB.XML Dispatcher Servlet is configured correctly. Also check if there is any spelling/name incorrectness.

Upvotes: 0

NinjaPop
NinjaPop

Reputation: 11

There is a possibility that you are missing a "/" in your web.xml file probably in: <servlet-mapping></servlet-mapping>

<url-pattern> missing "/" before pattern name </url-pattern>

possible issue

Upvotes: 0

user17196194
user17196194

Reputation: 1

This is the best solution. It worked for me.

Steps:-

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 Server and remove it. This will remove the Tomcat server configuration.

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

7-From the screen below, choose Apache Tomcat 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.

Upvotes: -2

aryan kathpal
aryan kathpal

Reputation: 9

This happens because your server HTTP port and your shutdown port are the same.

To resolve this, go to the server.xml file and search. There will be a SHUTDOWN port entry. Change it and your server will work.

Upvotes: 0

james danial
james danial

Reputation: 11

In my case, I had messed up up with my JAR files. My JAR files were corrupted. So delete existing JAR files and upload new JAR files. Hope this works. *Check 'Markers' tab for errors and warnings.

Upvotes: 1

Upeshitha
Upeshitha

Reputation: 1

  1. Open the 'server.xml' file. picture1

  2. Press ctrl + f and find the 'shutdown' word. Then change the port number. picture2

  3. done. Because when the connection port number and shutdown port number are the same, then it creates conflict. So, one port number we should change.

Upvotes: 0

Avinash Kumar
Avinash Kumar

Reputation: 21

I was facing a similar problem in my spring MVC project. The problem was in the web.xml file. So in Spring 5 before you configure your dispatcher servlet you have to use the tag

<absolute-ordering></absolute-ordering>

Worked fine for me. Happy Coding.

Upvotes: 2

tamoghna saha
tamoghna saha

Reputation: 1

I uninstalled tomcat server, deleted the server from eclipse and reinstalled, reattached tomcat. It's running fine now.

Upvotes: 0

lihinxgufin
lihinxgufin

Reputation: 1

  1. Go to directory (your workspace).metadata.plugins\org.eclipse.wst.server.core\tmp0\conf
  2. Open server.xml file on editor
  3. Delete <Context docBase="(your workspace)\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\(your old project)" path="/(your old project)" reloadable="true" source="org.eclipse.jst.jee.server:(your old project)"/>

there might be some left over from your old project. so, only delete projects that have not been used or that were previously deleted. because if you delete one line then your server will be able to run but not with your project. because some of your project lines were deleted too.

Upvotes: 0

Gustavo Feliciano
Gustavo Feliciano

Reputation: 61

Have you tried to put / in the webServlet above your class?

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

Upvotes: 1

Aron Kim
Aron Kim

Reputation: 3

There was once I had messed around the server.xml file, and unwittingly added a Context tag telling the server to load a project I wasn't looking to load, and therefore had not compiled. That threw the Server Tomcat v9.0 Server at localhost failed to start, which went away after I deleted that.

Upvotes: 0

tarun kumar143
tarun kumar143

Reputation: 441

Right click on the project you work on > Build Path > Configure Build Path > Libraries > Add External JARs--servlet-api.jar and jsp-api.jar if you are deploying web Application

Upvotes: 0

Rafsun Jany Arman
Rafsun Jany Arman

Reputation: 13

If you can't detect which project creates the problem then simply add and remove it in your server and run. If defective project is not anymore added to the server then server will run correctly. After detecting the problem you can simply follow the steps below.

If you are using data base connection with connection pooling then make sure @Resource(name="jdbc/dbName") is written before private DataSource dataSource in your servlet controller class. Just put it like this in your servlet controller class:

@Resource(name="jdbc/sakila")
private DataSource dataSource;

Upvotes: 0

amit kohan
amit kohan

Reputation: 1618

I had the same problem with Tomcat 9.xx and Eclipse. None of the given solutions helped me.

However, there is a missing step (for some of us) before recreating a new Server in Eclipse you may need to add the path to a jar file. The missing step was browsing to your /Tomcat-Directory/lib/servlet-api and adding servlet-api.jar

Steps:

1- Right click on the project you work on > Build Path > Configure Build Path > Libraries > Add External JARs

2- Select all JAR files from the Tomcat/bin and Tomcat/lib

3- Click "OK"

This made it work for me. I hope it will help you as well.

Thank you.

Upvotes: 2

Related Questions