Tuesday, November 20, 2012

Invalid servlet mapping in tomcat


A common exception ,"Invalid <url-pattern> servlet mapping" when deploying application server in tomcat. 
The url-pattern specification:
  • A string beginning with a ‘/’ character and ending with a ‘/*’ suffix is used for path mapping.
  • A string beginning with a ‘*.’ prefix is used as an extension mapping.
  • A string containing only the ’/’ character indicates the "default" servlet of the application. In this case the servlet path is the request URI minus the context path and the path info is null.
  • All other strings are used for exact matches only.

invalid web.xml:
<servlet>    <servlet-name>remoteLoggingServlet</servlet-name>    <servlet-class>com.google.gwt.logging.server.RemoteLoggingServiceImpl</servlet-class>  </servlet>    <servlet-mapping>    <servlet-name>remoteLoggingServlet</servlet-name>    <url-pattern>mweb/remote_logging</url-pattern>  </servlet-mapping>   

valid web.xml:
 <servlet>    <servlet-name>remoteLoggingServlet</servlet-name>    <servlet-class>com.google.gwt.logging.server.RemoteLoggingServiceImpl</servlet-class>  </servlet>    <servlet-mapping>    <servlet-name>remoteLoggingServlet</servlet-name>    <url-pattern>/mweb/remote_logging/*</url-pattern>  </servlet-mapping>