1

I am migrating an existing project from Tomcat 6 to 7. Upon startup I am encountering this logged error message:

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

Here the WEB-INF/web.xml line 309fff:

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

EDIT:

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

Here tomcat's 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>

I tried to play around with the mapping, but couldn't make any progress. Hope you can help!

Mario
  • 49
  • 2
  • 11
  • saveArtefactServlet /saveRestoration I think this has been duplicated. Please check another any occourences with same name exist in web.xml – Niju Jul 02 '13 at 13:00
  • In the we.xml file the servlet-name has been used multible times for different url-patterns. for tomcat 6 this was no problem, could this be the issue? – Mario Jul 02 '13 at 13:05
  • one servlet to many mappings ok, many servlets to one mapping, not ok – Keith Jul 02 '13 at 13:06
  • Can you please show servlet mapping for 'ArtefactServlet' – Niju Jul 02 '13 at 13:10
  • i added it to the question – Mario Jul 02 '13 at 13:19

2 Answers2

4

The error says :

The servlets named [ArtefactServlet] and [saveArtefactServlet] are both mapped to the url-pattern [/saveRestoration] which is not permitted

So tomcat doesn't know which servlet to be called when your url pattern is matched. Give different url patterns for these two servlets ArtefactServlet, saveArtefactServlet

vishnu viswanath
  • 3,794
  • 2
  • 36
  • 47
  • i guess this must be changed within the servlet itself incl. the url-pattern in the web.xml - correct? – Mario Jul 02 '13 at 13:09
  • in which file is your ArtefactServlet defined? – vishnu viswanath Jul 02 '13 at 13:11
  • is it possible for you to change the pattern of artifact servlet to something else? like /artifactServet? – vishnu viswanath Jul 02 '13 at 13:13
  • i just searched the code and the saveArtefactServlet doesn't seem to exist. ill commend it out and give it a try, thanks! – Mario Jul 02 '13 at 13:32
  • edit: the mappings point to various identical servlets. could this be a feature that i not supported within tomcat 7 any more? – Mario Jul 02 '13 at 13:38
  • its not possible. check out this link to know more about servlets and mappings. http://docs.oracle.com/cd/E13222_01/wls/docs92/webapp/configureservlet.html – vishnu viswanath Jul 02 '13 at 14:11
  • thank you for the link, i fixed the error and can continue with the correct pattern-recocnition! – Mario Jul 03 '13 at 06:21
0
java.lang.IllegalArgumentException: The servlets named...

I fetched this cause where I create new servlet in different package (name='syncro'). My servlet located in syncro.SynchronizeServlet And when I add information about this servlet in deployment descriptor (web.xml) I catch error: IllegalArgumentException

Example of incorrect descriptor part:

<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>

When I add correct path for servlet - error disappeared. Correct desc below:

<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!

Mikro Koder
  • 1,056
  • 10
  • 13