Lỗi server tomcat v9.0 server at localhost failed to start

Bạn đang tập tành lập trình web với Java? Bạn đang code JSP/Servlet? Hay xịn [cao cấp] hơn là Struts, Spring Framework,… Thôi nói chung là JavaEE Application đi cho tiện 😀

Vậy bạn biết Tomcat chứ?

Tomcat [Apache Tomcat] là một Java Servlet được phát triển bởi Apache Software Foundation [ASF]. Tomcat thi hành các ứng dụng Java Servlet và JavaServer Pages [JSP] từ Sun Microsystems và cung cấp một máy chủ HTTP cho ngôn ngữ Java thuần túy để thực thi các chương trình lệnh viết bằng ngôn ngữ Java. [anh wiki pé đia nói vậy]

[Ngoài Tomcat thì còn một số server nổi tiếng khác như Glassfish, JBoss, Wildfly, Jetty,…bạn có thể hỏi anh gồ để biết thêm chi tiết].

Một khi đã biết, đã sử dụng Tomcat rồi thì chắc hẳn bạn không còn xa lạ gì với những dòng thông báo lỗi kém thông tin như: “Server tomcat v7.0 server at localhost failed to start“, “Server tomcat v8.0 server at localhost failed to start“, “Server tomcat v9.0 server at localhost failed to start” hay nó hiển thị đỏ loè trên console “Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext“, “A child container failed during start“,… Còn nhiều lắm.

Thế thì cho mình hỏi một câu nhé: Bạn có cảm thấy lúng túng khi những lỗi đó ném ra trước mặt?

Trong tutorial này, mình sẽ cố gắng gỡ rối cho các bạn nhiều nhất có thể với các trường hợp lỗi Server Tomcat hay gặp, hiếm gặp và cách khắc phục nhé. Nhớ là chỉ xoay quanh vấn đề về lỗi và cách khắc phục lỗi khi sử dụng Apache Tomcat thôi [Có thể áp dụng để sửa lỗi trên các server khác vì lỗi chỉ từ code mà ra].

First, double click on the “Tomcat V9.0 server at localhost[started synchronized]” link then at that instant, you might see a page like the above image

Second, change the port number values to something near to default values such as 8006 and 8081

Third, save the page by ctrl+S

Fouth, start the tomcat server

Mohammed Anees

Hey there, welcome to aneescraftsmanship I am Mohammed Anees an independent developer/blogger. I like to share and discuss the craft with others plus the things which I have learned because I believe that through discussion and sharing a new world opens up

A very common problem Java developers face while working on web projects that need to be deployed in Tomcat is the error: 'Failed to Start...'

When we debug the application during development time and use Tomcat with Eclipse EE to deploy an application, the common error pops up below...

Server Tomcat v.xx Server at localhost failed to start.

This wastes several hours of developers' time. However, it's very easy to fix once you know the solution — it will also save you time. This error can be resolved in the following three cases:

1. Clean project and server

Or:

2. Remove .snap file from this directory

\.metadata\.plugins\org.eclipse.core.resources

Or

3. Remove temp file from this directory

\.metadata\.plugins\org.eclipse.wst.server.core

Another similar problem is shown below. This, too, is a very common and frequent problem.

This is how you can fix the Eclipse Error: Starting Apache Tomcat at localhost has encountered a problem!

The error looks something like this:

Most of the time, this means that Tomcat is already running in the background and Eclipse is trying to open it again on the same ports. This is obviously not possible, as the ports will be in use.

The issue typically arises from either the Eclipse or Tomcat process crash or being stuck.

This is how you can go about fixing the issue:

1. Go to server tab and double click on the Tomcat server, the configuration file for Tomcat will open and look like this:

2. Mark down the Port Number Tomcat is running on.

3. In my case, I see ports: 8013, 8014, and 8015

4. Go to command prompt and execute the following lines in succession [make sure to change ending port numbers to your own Tomcat ports]

netstat -o -n -a | findstr 0.0:8013 netstat -o -n -a | findstr 0.0:8014 netstat -o -n -a | findstr 0.0:8015 

Once you do so, you’ll get a result similar to this:

As you can see in the above screenshot, in my case, port 8013 is not running, but ports 8014 and 8015 are being used and they are running using PID [process id]: 15484.

This PID number [15484 in my case] is something you need to mark down.

5. Now, all you need to do is to go to your Windows Task Manager, click on Details Tab [in Windows 8], and sort the processes by PID number.

6. Find the Tomcat PID[s] that you found earlier, highlight the task [typically, it’ll be the Java process] and click “End Task Button”

7. Now, you can go back to Eclipse and run the task on your server as you would typically do. It should work again.

Chủ Đề