John Doe
John Doe

Reputation: 9764

Attributes in the web.xml's <web-app> don't work in Eclipse

I have a multi-module Maven project. It works fine in NetBeans. But not in Eclipse (EE Helios SR 1). In the web.xml file I have the following:

<web-app version="3.0" 
         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_3_0.xsd"
             metadata-complete="true">

I get 5 xml errors. Each one looks like that:

Attribute "version" must be declared for element type "web-app"

And the "version" part is changed to "xmlns:xsi" and so on in the other errors. I tried to change Dynamic Web Module version to 3.0, but it didn't help.

When moving to Eclipse I did mvn eclipse:eclipse -Dwtpversion=2.0 in the war module and mvn eclipse:eclipse in the others. I also installed m2e and m2e-wtp plugins. So, I suppose the project should work fine with that.

Why can't Eclipse work with a project, that's working in another IDE? I also had to change <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> to <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> on one of the JSP, which was a little strange too, because the old version of this uri worked in NetBeans.

Hope someone could clarify the reasons of its (unexpected for me) behavior and how this can be fixed.

Upvotes: 5

Views: 28305

Answers (1)

Bitmap
Bitmap

Reputation: 12538

Use 2.4 instead.

<?xml version="1.0" encoding="ISO-8859-1"?>
<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">

Edited.

Upvotes: 11

Related Questions