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.
The other solution is, click on your project > right-click > Java EE Tools > Generate Deployment Descriptor Stub as shown in the below image. And this will generate the web. xml file inside the WEB-INF folder with some pre-defined code as shown in the below image. And it will also resolve the error.
To get access to web. xml in Eclipse, even though it's in the webapps\ch11\WEB-INF directory, you can make it a linked file . To do that, right-click the ServletInPlace project, select New→ File, click the Advanced button, check the “Link to file in the file system” checkbox, and click the Browse button.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With