Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 348801

Summary: JavaEESingleRootCallback#hasDefaultWebResourceMappings returns errors for valid (but redundant) resource mappings
Product: [WebTools] WTP Java EE Tools Reporter: Roberto Sanchez Herrera <shr31223>
Component: jst.j2eeAssignee: Roberto Sanchez Herrera <shr31223>
Status: RESOLVED FIXED QA Contact: Chuck Bridgham <cbridgha>
Severity: normal    
Priority: P3 CC: ccc
Version: 3.2.4Flags: cbridgha: review+
Target Milestone: 3.2.5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed patch none

Description Roberto Sanchez Herrera CLA 2011-06-08 16:10:46 EDT
I have a web project with the following entries in the org.eclipse.wst.common.component file:

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="MyWeb">
        <wb-resource deploy-path="/" source-path="/WebContent"/>
        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
        <wb-resource deploy-path="/WEB-INF/web.xml" source-path="/WebContent/WEB-INF/web.xml"/>
        <property name="context-root" value="MyWeb"/>
        <property name="java-output-path" value="/MyWeb/build/classes"/>
    </wb-module>
</project-modules>


The method JavaEESingleRootCallback#hasDefaultWebResourceMappings returns the error JavaEESingleRootCallback.RUNTIME_PATH_NOT_ROOT_OR_WEBINF_CLASSES (and therefore the project is not considered as single root) because of this entry:

<wb-resource deploy-path="/WEB-INF/web.xml" source-path="/WebContent/WEB-INF/web.xml"/>

But technically, that entry should not make the project non-single root, because 
there is another entry that maps everything under /WebContent to /. The entry is redundant and unnecessary , and we could warn the caller of this.
Comment 1 Roberto Sanchez Herrera CLA 2011-06-08 17:24:57 EDT
Created attachment 197649 [details]
Proposed patch

With this patch, a warning is returned (instead of an error) in JavaEESingleRootCallback#hasDefaultWebResourceMappings when a redundant entry is found. By redundant entry, I mean that the path mapped to / (in this case, /WebContent) concatenated to the deploy path of the entry (in this case, /WEB-INF/web.xml") is equals to the source path of the entry. This way, we would not allow entries that map files or folders to other folders different from the source path (e.g.,mapping /WebContent/WEB-INF/web.xml to /WEB-INF/otherFolder/web.xml)
Comment 2 Chuck Bridgham CLA 2011-06-20 16:40:14 EDT
approved
Comment 3 Roberto Sanchez Herrera CLA 2011-06-20 18:04:36 EDT
Code committed to R3_2_maintenance for WTP 3.2.5. I will keep this defect open
until branch for 3.3.1 is available to commit to 3.3.1 and HEAD
Comment 4 Roberto Sanchez Herrera CLA 2011-06-23 11:29:41 EDT
Committed to HEAD. That will cover WTP 3.3.1 and 3.4