Server Tomcat v7.0 Server at localhost failed to start. One of the possible causes of the error is tomcatlocalhost.

Source: Internet
Author: User

Server Tomcat v7.0 Server at localhost failed to start. One of the possible causes of the error is tomcatlocalhost.
Story:

Learning Servlet, suddenly found this problem when starting Tomcat

Synopsis:

When learning servlet, you can't even get started with the server. I have to think about it. Then I am Baidu, I'm FQgoogle, and I am looking for stackoverflow. I found a lot of answers, such as stackoverflow

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

You can solve this problem by deleting a. snap file. Stackoverflow links are as follows.

In Baidu, Myexception network provides the answer:1. Port occupied,2. the startup time is not enough,3. Problems Caused by eclipse 4. restart the computer (the most stupid way is to get bored if it keeps appearing .).Below is the original article link. None of these answers are for me. Therefore, we will try to use Google in the future. Baidu feels unreliable.

Story truth:

In the powerful software of eclipse, we omit a lot of time for manual code writing. The process is as follows:

 

Click finish in to generate the following code.

For example, in eclipse, after we create a new servlet File, the code will generate the following large piece of code.

 1 import java.io.IOException; 2 import javax.servlet.ServletException; 3 import javax.servlet.annotation.WebServlet; 4 import javax.servlet.http.HttpServlet; 5 import javax.servlet.http.HttpServletRequest; 6 import javax.servlet.http.HttpServletResponse; 7  8 /** 9  * Servlet implementation class ServletDemo10  */11 @WebServlet("/ServletDemo")12 public class ServletDemo extends HttpServlet {13     private static final long serialVersionUID = 1L;14        15     /**16      * @see HttpServlet#HttpServlet()17      */18     public ServletDemo() {19         super();20         // TODO Auto-generated constructor stub21     }22 23     /**24      * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)25      */26     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {27         // TODO Auto-generated method stub28         response.getWriter().append("Served at: ").append(request.getContextPath());29     }30 31     /**32      * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)33      */34     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {35         // TODO Auto-generated method stub36         doGet(request, response);37     }38 39 }

Note that there is an annotation.

@WebServlet("/ServletDemo")

This annotation is generated by eclipse for us, and the problem lies exactly in this. We know that every time we create a servlet. configure the ing relationship in the xml file so that the server can receive the request and send the request to the specified Servlet after an address is typed in the browser. The role of web. xml is here. Its code is as follows:

<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <servlet> <servlet-name>ServletDemo</servlet-name> <servlet-class>com.vivizhang.servlet.HelloWorldServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>ServletDemo</servlet-name> <url-pattern>/HelloServlet</url-pattern> </servlet-mapping></web-app>

So the truth isConfigurationAndAutomatically Generated AnnotationConflict, resulting in the following error (screenshot ):

A child container failed during startjava. util. concurrent. executionException: org. apache. catalina. lifecycleException: Failed to start component [StandardEngine [Catalina]. standardHost [localhost]. standardContext [/ServletDemo] at java. util. concurrent. futureTask $ Sync. innerGet (FutureTask. java: 252) at java. util. concurrent. futureTask. get (FutureTask. java: 111) at org. apache. catalina. core. containerBase. startInternal (ContainerBase. java: 1120) at org. apache. catalina. core. standardHost. startInternal (StandardHost. java: 819) at org. apache. catalina. util. lifecycleBase. start (LifecycleBase. java: 147) at org. apache. catalina. core. containerBase $ StartChild. call (ContainerBase. java: 1572) at org. apache. catalina. core. containerBase $ StartChild. call (ContainerBase. java: 1562) at java. util. concurrent. futureTask $ Sync. innerRun (FutureTask. java: 334) at java. util. concurrent. futureTask. run (FutureTask. java: 166) at java. util. concurrent. threadPoolExecutor. runWorker (ThreadPoolExecutor. java: 1145) at java. util. concurrent. threadPoolExecutor $ Worker. run (ThreadPoolExecutor. java: 615) at java. lang. thread. run (Thread. java: 722) Caused by: org. apache. catalina. lifecycleException: Failed to start component [StandardEngine [Catalina]. standardHost [localhost]. standardContext [/HelloServlet] at org. apache. catalina. util. lifecycleBase. start (LifecycleBase. java: 153 )... 7 moreCaused by: java. lang. illegalArgumentException: The servlets named [ServletDemo] and [com. vivizhang. servlet. servletDemo] are both mapped to the url-pattern [/ServletDemo] which is not permitted at org. apache. catalina. deploy. webXml. addServletMapping (WebXml. java: 293) at org. apache. catalina. startup. contextConfig. processAnnotationWebServlet (ContextConfig. java: 2462) at org. apache. catalina. startup. contextConfig. processAnnotationsStream (ContextConfig. java: 2137) at org. apache. catalina. startup. contextConfig. processAnnotationsFile (ContextConfig. java: 2098) at org. apache. catalina. startup. contextConfig. processAnnotationsFile (ContextConfig. java: 2090) at org. apache. catalina. startup. contextConfig. processAnnotationsFile (ContextConfig. java: 2090) at org. apache. catalina. startup. contextConfig. processAnnotationsFile (ContextConfig. java: 2090) at org. apache. catalina. startup. contextConfig. processAnnotationsFile (ContextConfig. java: 2090) at org. apache. catalina. startup. contextConfig. webConfig (ContextConfig. java: 1304) at org. apache. catalina. startup. contextConfig. configureStart (ContextConfig. java: 889) at org. apache. catalina. startup. contextConfig. lifecycleEvent (ContextConfig. java: 386) at org. apache. catalina. util. lifecycleSupport. fireLifecycleEvent (LifecycleSupport. java: 117) at org. apache. catalina. util. lifecycleBase. fireLifecycleEvent (LifecycleBase. java: 90) at org. apache. catalina. core. standardContext. startInternal (StandardContext. java: 5472) at org. apache. catalina. util. lifecycleBase. start (LifecycleBase. java: 147 )... 7 more September 18 4:40:37 org. apache. catalina. core. containerBase startInternalSEVERE: A child container failed during startjava. util. concurrent. executionException: org. apache. catalina. lifecycleException: Failed to start component [StandardEngine [Catalina]. standardHost [localhost] at java. util. concurrent. futureTask $ Sync. innerGet (FutureTask. java: 252) at java. util. concurrent. futureTask. get (FutureTask. java: 111) at org. apache. catalina. core. containerBase. startInternal (ContainerBase. java: 1120) at org. apache. catalina. core. standardEngine. startInternal (StandardEngine. java: 300) at org. apache. catalina. util. lifecycleBase. start (LifecycleBase. java: 147) at org. apache. catalina. core. standardService. startInternal (StandardService. java: 444) at org. apache. catalina. util. lifecycleBase. start (LifecycleBase. java: 147) at org. apache. catalina. core. standardServer. startInternal (StandardServer. java: 738) at org. apache. catalina. util. lifecycleBase. start (LifecycleBase. java: 147) at org. apache. catalina. startup. catalina. start (Catalina. java: 693) at sun. reflect. nativeMethodAccessorImpl. invoke0 (Native Method) at sun. reflect. nativeMethodAccessorImpl. invoke (NativeMethodAccessorImpl. java: 57) at sun. reflect. delegatingMethodAccessorImpl. invoke (DelegatingMethodAccessorImpl. java: 43) at java. lang. reflect. method. invoke (Method. java: 601) at org. apache. catalina. startup. bootstrap. start (Bootstrap. java: 294) at org. apache. catalina. startup. bootstrap. main (Bootstrap. java: 428) Caused by: org. apache. catalina. lifecycleException: Failed to start component [StandardEngine [Catalina]. standardHost [localhost] at org. apache. catalina. util. lifecycleBase. start (LifecycleBase. java: 153) at org. apache. catalina. core. containerBase $ StartChild. call (ContainerBase. java: 1572) at org. apache. catalina. core. containerBase $ StartChild. call (ContainerBase. java: 1562) at java. util. concurrent. futureTask $ Sync. innerRun (FutureTask. java: 334) at java. util. concurrent. futureTask. run (FutureTask. java: 166) at java. util. concurrent. threadPoolExecutor. runWorker (ThreadPoolExecutor. java: 1145) at java. util. concurrent. threadPoolExecutor $ Worker. run (ThreadPoolExecutor. java: 615) at java. lang. thread. run (Thread. java: 722) Caused by: org. apache. catalina. lifecycleException: A child container failed during start at org. apache. catalina. core. containerBase. startInternal (ContainerBase. java: 1128) at org. apache. catalina. core. standardHost. startInternal (StandardHost. java: 819) at org. apache. catalina. util. lifecycleBase. start (LifecycleBase. java: 147 )... 7 more September 18 4:40:37 org. apache. catalina. startup. catalina startSEVERE: The required Server component failed to start so Tomcat is unable to start.org. apache. catalina. lifecycleException: Failed to start component [StandardServer [8006] at org. apache. catalina. util. lifecycleBase. start (LifecycleBase. java: 153) at org. apache. catalina. startup. catalina. start (Catalina. java: 693) at sun. reflect. nativeMethodAccessorImpl. invoke0 (Native Method) at sun. reflect. nativeMethodAccessorImpl. invoke (NativeMethodAccessorImpl. java: 57) at sun. reflect. delegatingMethodAccessorImpl. invoke (DelegatingMethodAccessorImpl. java: 43) at java. lang. reflect. method. invoke (Method. java: 601) at org. apache. catalina. startup. bootstrap. start (Bootstrap. java: 294) at org. apache. catalina. startup. bootstrap. main (Bootstrap. java: 428) Caused by: org. apache. catalina. lifecycleException: Failed to start component [StandardService [Catalina] at org. apache. catalina. util. lifecycleBase. start (LifecycleBase. java: 153) at org. apache. catalina. core. standardServer. startInternal (StandardServer. java: 738) at org. apache. catalina. util. lifecycleBase. start (LifecycleBase. java: 147 )... 7 moreCaused by: org. apache. catalina. lifecycleException: Failed to start component [StandardEngine [Catalina] at org. apache. catalina. util. lifecycleBase. start (LifecycleBase. java: 153) at org. apache. catalina. core. standardService. startInternal (StandardService. java: 444) at org. apache. catalina. util. lifecycleBase. start (LifecycleBase. java: 147 )... 9 moreCaused by: org. apache. catalina. lifecycleException: A child container failed during start at org. apache. catalina. core. containerBase. startInternal (ContainerBase. java: 1128) at org. apache. catalina. core. standardEngine. startInternal (StandardEngine. java: 300) at org. apache. catalina. util. lifecycleBase. start (LifecycleBase. java: 147 )... 11 more

The problem is:

The servlets named [ServletDemo] and [com.vivizhang.servlet.ServletDemo] are both mapped to the url-pattern [/ServletDemo] which is not permitted
Solution to the story:

You can choose to delete the ing in web. xml, or comment out the automatically generated annotation so that no conflict exists. You can choose either of them to leave it behind.

Follow-up stories:

Of course, the reason for this problem is certainly more than me. There must be other reasons. We recommend that you refer to stackoverflow. If you forget Baidu, it will be a waste of time.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.