Wednesday, August 24, 2011

The content of element type must match

Problem :


I have the following error :
The content of element type "filter" must match  "(icon?,filter-name,display-name?,description?,filter-class,init-param*)".

Here is an extract of my web.xml :
<filter> 
    <display-name>RichFaces Filter</display-name>
    <filter-name>richfaces</filter-name>
    <filter-class>org.ajax4jsf.Filter</filter-class> 
</filter> 


Solution :

In fact, the solution is in the message.The message said that there is an order in the tags filter-mappings.
You have to put first filter-name then url-pattern or servlet name.
So you have to correct like that :

<filter> 
    <filter-name>richfaces</filter-name>
    <display-name>RichFaces Filter</display-name>  
    <filter-class>org.ajax4jsf.Filter</filter-class> 
</filter> 

An important note, this error appear because I put the following dtd in my web.xml :

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>

Or it's not the last dtd.Now it has change and it seems that the good manner is the following :

<?xml version="1.0"?>
<web-app version="2.5" 
    xmlns="http://java.sun.com/xml/ns/javaee"
        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_5.xsd">

No comments:

Post a Comment