Community
Participate
Working Groups
Build Identifier: There are two issues. 1)Using an object of WebArtifactEdit, getWebApp() method is called.This internally calls org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit.getDeploymentDescriptorRoot().Here getDeploymentDescriptorResource().getContents() is called and if no contents exist,addWebAppIfNecessary is called to create a web.xml file. Then contents.get(0) is directly returned which throws an IndexOutOfBoundsException if no contents exist.A check has to be added like return contents.size() > 0?(EObject) contents.get(0):null; to prevent this. 2)Assuming that 1) is fixed,there is another issue of web-app version not getting added in web.xml. The scenario is that web.xml doesn't exist in the project and WebArtifactEdit.getWebApp() is called.As discussed in 1), addWebAppIfNecessary is called to create a web.xml file.The function internally stores the webapp id,creates the list of welcome files.It also sets the version of webapp(through a notification in aResource.getContents().add(webAppNew);) based on module version id.But it finally creates a web.xml file with just a line(<?xml version="1.0" encoding="UTF-8"?>) and saves it. Another call to WebArtifactEdit.getWebApp() again sets the webappid and the list of welcome files, but it doesn't set the version of the webapp(no notification in aResource.getContents().add(webAppNew) comes to set it).The web.xml is updated with the other contents like welcome files,webapp tag etc.,but version is not set which is flagged as an XML Problem.The version of the web-app has to be set in the web.xml file. Reproducible: Always
Found in org.eclipse.jst.j2ee.web v201004190850
Badri, looking at the version id you provided for the plugin, I assume that you are using Helios, which corresponds to WTP 3.2. If this is not correct, please let us know.
(In reply to comment #0) Also found that as a part of issue 2), the xsi:schemaLocation in the web.xml is always http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd inspite of selecting Dynamic web module version as something else.
Assigning to Hari for initial investigation.
The problem here is that calls to WebArtifactEdit for Web 3.0 projects without a deployment descriptor result in a Servlet 2.4 web.xml being created. WebArtifactEdit is coded for Servlet 2.1 to 2.4 support, and can somewhat tolerate 2.5 and 3.0, however, it is not the correct way to access the Web 2.5 and Web 3.0 models and can result in undesireable side effects, such as the creation of a Servlet 2.4 web.xml.