Tomcat的7:无效映射(java.lang.IllegalArgumentException异常

2019-10-18 07:36发布

这个问题已经在这里有一个答案:

  • java.lang.IllegalArgumentException异常:命名为[X]和[Y]的小服务程序都映射到未许可的URL模式[/ URL] 5个答案

我迁移从Tomcat 6现有项目到7启动时,我遇到此记录的错误信息:

Jul 02, 2013 2:38:39 PM org.apache.catalina.startup.ContextConfig parseWebXml
SEVERE: Parse error in application web.xml file at jndi:/localhost/padd/WEB-INF/web.xml
org.xml.sax.SAXParseException; systemId: jndi:/localhost/padd/WEB-INF/web.xml; lineNumber: 309; columnNumber: 21; Error at (309, 21) : The servlets named [ArtefactServlet] and [saveArtefactServlet] are both mapped to the url-pattern [/saveRestoration] which is not permitted
    at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2687)
    ...
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: The servlets named [ArtefactServlet] and [saveArtefactServlet] are both mapped to the url-pattern [/saveRestoration] which is not permitted

在这里,WEB-INF / web.xml文件行309fff:

  <servlet-mapping>
    <servlet-name>saveArtefactServlet</servlet-name>
    <url-pattern>/saveRestoration</url-pattern>
  </servlet-mapping>

编辑:

  <servlet-mapping>
    <servlet-name>ArtefactServlet</servlet-name>
    <url-pattern>/saveRestoration</url-pattern>
  </servlet-mapping>

这里的tomcat的web.xml:

<servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>

    <!-- The mappings for the JSP servlet -->
    <servlet-mapping>
        <servlet-name>jsp</servlet-name>
        <url-pattern>*.jsp</url-pattern>
        <url-pattern>*.jspx</url-pattern>
    </servlet-mapping>

我试着玩的映射,但未能取得任何进展。 希望能帮到你!

Answer 1:

错误说:

命名的servlet [ArtefactServlet]和[saveArtefactServlet]都被映射到未许可的URL模式[/ saveRestoration]

所以Tomcat不知道什么时候你的URL匹配模式被称为哪个servlet。 给不同的URL模式这两个servlet的ArtefactServlet,saveArtefactServlet



Answer 2:

java.lang.IllegalArgumentException: The servlets named...

我取这个原因,我创建不同的包(名称=“SYNCRO”)新的servlet。 我的servlet位于syncro.SynchronizeServlet当我加入这个servlet的部署描述符(web.xml)的信息我赶上错误: 抛出:IllegalArgumentException

不正确描述符部分的实施例:

<servlet>
    <description></description>
    <display-name>SynchronizeServlet</display-name>
    <servlet-name>SynchronizeServlet</servlet-name>
    <servlet-class>SynchronizeServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>SynchronizeServlet</servlet-name>
    <url-pattern>/SynchronizeServlet</url-pattern>
    <url-pattern>/SynServlet</url-pattern>
  </servlet-mapping>

当我添加正确的路径的servlet - 错误消失。 下面正确说明:

<servlet>
    <description></description>
    <display-name>syncro.SynchronizeServlet</display-name>
    <servlet-name>syncro.SynchronizeServlet</servlet-name>
    <servlet-class>syncro.SynchronizeServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>syncro.SynchronizeServlet</servlet-name>
    <url-pattern>/SynchronizeServlet</url-pattern>
    <url-pattern>/SynServlet</url-pattern>
  </servlet-mapping>

==> 73!



文章来源: Tomcat 7: Invalid mapping (java.lang.IllegalArgumentException) [duplicate]