Java – start Tomcat war

I installed Tomcat server on my computer

I created a set of servlets in eclipse and exported them in war format

When I deploy to the server and let it start, I receive the following error:

FALLO - No se pudo arrancar la aplicación en trayectoria de contexto /Middleware
FALLO - EnconTrada excepción org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Middleware]]

If I go to the Tomcat log file for more details, see the following:

Caused by: java.lang.IllegalArgumentException: The servlets named [reunionServlet] and [servlet.ReunionServlet] are both mapped to the url-pattern [/ReunionServlet] which is not permitted
at org.apache.catalina.deploy.WebXml.addServletMapping(WebXml.java:335)
at org.apache.catalina.startup.ContextConfig.processAnnotationWebServlet(ContextConfig.java:2457)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2139)
at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2100)
at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2093)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1300)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:369)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5269)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

What's the problem?

I don't know if the problem is related to the web file XML related Its contents are as follows

Solution

Read the first three lines of the stack trace, which will tell you exactly what happened: as javadev correctly answered, you mapped two servlets to the same URL pattern One of them is obviously on your web In XML, the other is probably in some comments (because the third line of your stack trace is discarded)

Locate the servlet in question and change the comment or web XML declaration, you'll be fine

Interesting enough: in both cases, the offending servlet seems to be the same - for example, you're already on the web The mapping of the reunionservlet and the annotated servlet are declared in XML Reunion servlet (your package name seems to be "servlet" – very generic) So you basically just need to delete one of the two statements, and everything should work as expected

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>