Thursday, July 09, 2009

Eclipse : Problems with web.xml

If you use Eclipse with the Sysdeo plugin you sometimes get problems with web.xml when you add more servlet mappings. The message is:

The content of element type "web-app" must match "(icon?,display-
name?,description?,distributable?,context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-
mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,resource-env-
ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-
ref*)".


e.g. you may have


web-app
servlet A
servlet-name
servlet-class
/servlet

servlet-mapping A
servlet-name
url-pattern
/servlet-mapping

servlet B
servlet-name
servlet-class
/servlet

servlet-mapping B
servlet-name
url-pattern
/servlet-mapping

/web-app


The problem is in the order. You can't intermix servlet and servlet-mapping. All the servlets have to come first followed by all the servlet-mappings. So the above would look like:


web-app
servlet A
servlet-name
servlet-class
/servlet

servlet B
servlet-name
servlet-class
/servlet

servlet-mapping A
servlet-name
url-pattern
/servlet-mapping

servlet-mapping B
servlet-name
url-pattern
/servlet-mapping

/web-app


You can check this by : Right click inside the xml window - Validate.

Enjoy!

1 comment:

Daily Mobile said...
This comment has been removed by a blog administrator.