A Weird Exception, java.lang.IllegalArgumentException: Filter mapping specifies an unknown filter name “FilterName”
Today i found an exception while deploying my .war application to Tomcat web server for production usage, very weird because i never had this exception on my IDE before. This is the complete exception stacktrace,
Caused by: java.lang.IllegalArgumentException: Filter mapping specifies an unknown filter name FilterName at org.apache.catalina.core.StandardContext.addFilterMap(StandardContext.java:2506) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source)
below is my web.xml content,
<?xml version="1.0" encoding="UTF-8"?> <web-app id="crm" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_4.xsd"> <display-name>edw</display-name> <context-param> <param-name>edw</param-name> <param-value>edw</param-value> </context-param> <filter-mapping> <filter-name>FilterName</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>FilterName</filter-name> <filter-class>com.edw.filter.FilterName</filter-class> </filter> </web-app>
How to fix it is actually very simple, i only need to swap between
<?xml version="1.0" encoding="UTF-8"?> <web-app id="crm" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_4.xsd"> <display-name>edw</display-name> <context-param> <param-name>edw</param-name> <param-value>edw</param-value> </context-param> <filter> <filter-name>FilterName</filter-name> <filter-class>com.edw.filter.FilterName</filter-class> </filter> <filter-mapping> <filter-name>FilterName</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
Weird eh
No Comments