【问题标题】:java.lang.IllegalArgumentException: The servlets are both mapped to the url-pattern [/foo] which is not permitted [duplicate]java.lang.IllegalArgumentException:servlet 都映射到不允许的 url 模式 [/foo] [重复]
【发布时间】:2015-06-15 16:23:01
【问题描述】:

我在尝试启动服务器时收到上述错误。重要提示,对于任何其他 Web 应用程序,服务器都可以正常启动。只是这个特定的 Web 应用程序不起作用。这是完整的堆栈跟踪:

Caused by: java.lang.IllegalArgumentException: The servlets named [DOMServlet] and [edu.unsw.comp9321.DOMServlet] are both mapped to the url-pattern [/DOMServlet] which is not permitted
    at org.apache.catalina.deploy.WebXml.addServletMapping(WebXml.java:293)
    at org.apache.catalina.startup.ContextConfig.processAnnotationWebServlet(ContextConfig.java:2428)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2103)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2064)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2057)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2057)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2057)
    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:5412)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 7 more

【问题讨论】:

  • “名为 [DOMServlet] 和 [edu.unsw.comp9321.DOMServlet] 的 servlet 都映射到不允许的 url 模式 [/DOMServlet]”。你还需要什么?
  • 谢谢,这解决了!抱歉应该更详细地阅读跟踪!

标签: tomcat servlets illegalargumentexception url-pattern servlet-mapping


【解决方案1】:

您好,您应该检查您的 web.xml 文件,因为您有 2 个 servlet DOMServletedu.unsw.comp9321.DOMServlet 引用相同的 url 模式,如果您没有在 web.xml 中映射 servlet,请检查您的代码中的类用@WebServlet注释。

另一个重要的一点是,也许你在你的 tomcat 目录中部署了另一个包含 DOMServlet 的应用程序,检查你的 webapps 目录并清理它以确保你没有额外的战争带有重复的 url 模式。或许您可以向我们提供更多信息以帮助您。

干杯

【讨论】:

  • 谢谢,解决了!抱歉应该更详细地阅读跟踪!
  • 您可以选择您提出的问题的任何答案作为“已接受”答案。
猜你喜欢
  • 1970-01-01
  • 2016-03-07
  • 2013-01-20
  • 2015-04-26
  • 2014-10-01
  • 2014-01-31
  • 1970-01-01
  • 2016-11-26
  • 2014-01-22
相关资源
最近更新 更多