title: IllegalArgumentException: The servlets named [program] and [com.test.Servlet] are both mapped to the url-pattern [/Servlet] which is not permitted
body: <p>I have just started working on <code>Servlets</code>. I have created a dynamic web project, and I was trying to copy the <code>servlet-api.jar</code> into lib. It didnt work out. So, I copied the jar in the workspace manually by going into the location in drive and then configured to the build path. When I ran the <code>tomcat server 8.0</code>, its stopping with some errors. When I comment out the servlet configuration in <code>web.xml</code>, the server starts. There is some problem in configuring. Hope the following error helps.</p>
  
  <h2>Java code</h2>
  
  <pre><code> package com.test;
  
  import java.io.IOException;
  import javax.servlet.ServletException;
  import javax.servlet.annotation.WebServlet;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
  
  @WebServlet("/Servlet")
  public class Servlet extends HttpServlet {
      private static final long serialVersionUID = 1L;
  
       public Servlet() {
          super();
      }
  
      /**
       * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
   */
      protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       System.out.println("In Do Get");
      response.getWriter().append("Served at: ").append(request.getContextPath());
  }
  
    /**
   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      System.out.println("In DO Post");
      doGet(request, response);
  }
  
  }
  </code></pre>
  
  <h2>Web.xml</h2>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
   &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns="http://xmlns.jcp.org/xml/ns/javaee"  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org /xml/ns/javaee/web-app_3_1.xsd" version="3.1"&gt;
  &lt;display-name&gt;Servlet&lt;/display-name&gt;
   &lt;welcome-file-list&gt;
   &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;    
  &lt;/welcome-file-list&gt;
  &lt;servlet&gt;
    &lt;servlet-name&gt;program&lt;/servlet-name&gt;
    &lt;servlet-class&gt;com.test.Servlet&lt;/servlet-class&gt;
   &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;program&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/Servlet&lt;/url-pattern&gt;
     &lt;/servlet-mapping&gt;
   &lt;/web-app&gt;
  </code></pre>
  
  <h2>Error</h2>
  
  <pre><code>SEVERE: A child container failed during start
  java.util.concurrent.ExecutionException:  org.apache.catalina.LifecycleException: Failed to start component  [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Servlet]]
  at java.util.concurrent.FutureTask.report(Unknown Source)
  at java.util.concurrent.FutureTask.get(Unknown Source)
  at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
  at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871)
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
  at java.util.concurrent.FutureTask.run(Unknown Source)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  at java.lang.Thread.run(Unknown Source)
  Caused by: org.apache.catalina.LifecycleException: Failed to start component   [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Servlet]]
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
  ... 6 more
  Caused by: java.lang.IllegalArgumentException: The servlets named [program] and [com.test.Servlet] are both mapped to the url-pattern [/Servlet] which is not permitted
  at org.apache.tomcat.util.descriptor.web.WebXml.addServletMapping(WebXml.java:308)
  at org.apache.catalina.startup.ContextConfig.processAnnotationWebServlet(ContextConfig.java:2373)
  at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2055)
  at org.apache.catalina.startup.ContextConfig.processAnnotationsWebResource(ContextConfig.java:1940)
  at org.apache.catalina.startup.ContextConfig.processAnnotationsWebResource(ContextConfig.java:1934)
  at org.apache.catalina.startup.ContextConfig.processAnnotationsWebResource(ContextConfig.java:1934)
  at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1147)
  at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:779)
  at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:306)
  at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
  at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
  at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5150)
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
  ... 6 more
  </code></pre>