Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

web.xml Versioning

I am building a web application in Eclipse and get a version issue in web.xml:

<web-app version="2.4" xmlns="java.sun.com/xml/ns/javaee"
   xmlns:xsi="w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="java.sun.com/xml/ns/javaee java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

The error is:

cvc-enumeration-valid: Value '2.4' is not facet-valid with respect to enumeration '[2.5]'.
It must be a value from the enumeration.

The project facet shows version 2.4 for both the Dynamic Web Module and the Servlet API.

like image 598
lowLatency Avatar asked Jan 19 '12 08:01

lowLatency


1 Answers

If you declare your app in Eclipse to be a 2.5 app, and say that your web-app version is 2.4, but link to the schema of the 2.5 version (web-app_2_5.xsd), it will obviously not work

<web-app version="2.4" 
         xmlns="java.sun.com/xml/ns/javaee"
         xmlns:xsi="w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="java.sun.com/xml/ns/javaee 
                             java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
                                                                 ^-- HERE!

Use the 2.4 version:

<web-app 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/j2ee 
                             http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
like image 155
JB Nizet Avatar answered Sep 28 '22 07:09

JB Nizet