Search code examples
eclipsetomcatservletsillegalargumentexceptionurl-pattern

java.lang.IllegalArgumentException: Invalid <url-pattern> xmlServletPath in servlet mapping


When I start Tomcat v7.0 Server from Servers tab in Eclipse, a problem occurred message box appears saying:

Starting Tomcat v7.0 Server at localhost has encountered a problem.

Server Tomcat v7.0 Server at localhost failed to start.

I am a beginner in this area and searched for every similar question on stackoverflow, tried the solutions given by others, but none worked. What can I do to solve the issue?

web.xml is

<?xml version="1.0" encoding="UTF-8"?> 

<web-app xmlns:xsi="w3.org/2001/XMLSchema-instance" ; xmlns="java.sun.com/xml/ns/javaee" ; xsi:schemaLocation="java.sun.com/xml/ns/javaee  java.sun.com/xml/ns/javaee/web-app_3_0.xsd" ; id="WebApp_ID" version="3.0"> 

<display-name>SimpleServletProject</display-name> 

<servlet> <servlet-name>xmlServlet</servlet-name> 

          <servlet-class>org.swechchha.XmlServlet</servlet-class>

 </servlet> 

<servlet-mapping>

     <servlet-name>xmlServlet</servlet-name>

     <url-pattern>xmlServletPath</url-pattern> </servlet-mapping>   

 </web-app> –

Logs are here:

SEVERE: A child container failed during start

Caused by: java.lang.IllegalArgumentException: Invalid <url-pattern> xmlServletPath in servlet mapping

Solution

  • got the solution. did a silly mistake in web.xml file. missed a '/' .It must be

        <url-patterns>/xmlServletPath</url-patterns>
    

    If still the server doesn't start, it may be it needs more time, increase the timeout entry from default '45' by double clicking your server in 'Servers' tab.