tomcat启动失败,一闪而过在eclipse中
出现的问题描述如下:
用到页面:
- index.jsp
- web.xml
- UploadFile
- 出现错误
控制台打印的信息如下:
严重: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
Caused by: java.lang.IllegalArgumentException: The servlets named [uploadFile] and [com.cy.servlet.UploadFile] are both mapped to the url-pattern [/upload] which is not permitted
严重: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/UploadFile]]
Caused by: java.lang.IllegalArgumentException: The servlets named [uploadFile] and [com.cy.servlet.UploadFile] are both mapped to the url-pattern [/upload] which is not permitted
严重: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
org.apache.catalina.LifecycleException: Failed to start component
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
java.lang.NullPointerException
通过我们分析上面错误的描述,我们确定了有一个点是关键点:
Caused by: java.lang.IllegalArgumentException: The servlets named [uploadFile] and [com.cy.servlet.UploadFile] are both mapped to the url-pattern [/upload] which is not permitted
翻译大概内容就是:在servlet中注解的名字和在web.xml中url-pattern映射的名字相同了,这是不被允许的。
此时我们我们就可以到我们的servlet中和web.xml中检查是不是重复定义了这个名字,如果有的话,就把其中一个去掉,因为加上注解和web.xml中的配置只能选择其中的一种。