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

Bug 353834

Summary: JSF Facet completely overwrites the web.xml if the deployment assembly contains several folders
Product: [WebTools] Java Server Faces Reporter: Fred Bricon <fbricon>
Component: CoreAssignee: Ian Trimble <ian.trimble>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: raghunathan.srinivasan
Version: unspecified   
Target Milestone: 3.2.5   
Hardware: PC   
OS: Linux   
Whiteboard:
Bug Depends on: 355150    
Bug Blocks:    
Attachments:
Description Flags
Sample project to reproduce the issue none

Description Fred Bricon CLA 2011-08-03 19:57:24 EDT
Build Identifier: I20110613-1736

Hi,

Since m2e-wtp 0.13.0, a typical maven-powered dynamic web project defines 2 folders its .component :
1 - target/m2e/web-resources/ : contains generated files
2 - src/main/webapp/ : contains user resources under SCM

Both folders are deployed via the WTP server adapter. The target folder is put in first position because we sometimes need to override user resources (ex. dynamically replacing placeholders in configuration files) and WTP deploys the first resource it finds.

When you add the JSF Facet to such project, and ask to add the faces servlet to the web.xml, the JSFFacetInstallDelegate pretty much does the following :
- looks for the first folder found in .component (finds target/*)
- finds no web.xml so generates an empty webxml model
- serialize the new model to the web.xml it finds in src/main/webapp
=> the user web.xml is then totally overwritten.

This is a MAJOR issue for m2eclipse-wtp and JBoss Tools users, where the JSF Facet is automatically installed if a JSF dependency is detected in the project classpath.

So :
1 - The process should be consistent : Find a web.xml in a directory and stick to it when it writes updates
2 - We should be able to pass an IPath or an IFolder output directory property to the Delegate. It would allow adopters to point the Delegate to the correct generation location, the right web.xml would be changed, faces-config.xml would be added alongside.




Reproducible: Always

Steps to Reproduce:
This can be reproduced using stock WTP projects. You can import the Web project attached to this issue. Check the content of WebContent/WEB-INF/web.xml
1. open the project properties
2. In project facets, choose JSF 1.2
3. Click on the "Further configuration Available" link
4. JSF Implem. Library : Make sure disable library configuration is selected
5. Make sure "Configure JSF Servlet in DD" is checked
6. Click on OK, then OK to complete the facet change
7. Check the web.xml has been totally overwritten in WebContent/WEB-INF/
Comment 1 Fred Bricon CLA 2011-08-03 19:58:13 EDT
Created attachment 200868 [details]
Sample project to reproduce the issue
Comment 2 Fred Bricon CLA 2011-08-04 03:29:10 EDT
Note that I'm aware of model.setBooleanProperty(IJSFFacetInstallDataModelProperties.CONFIGURE_SERVLET,false) which prevents messing with web.xml updates. The problem occurs when it's set to true.
Comment 3 Ian Trimble CLA 2011-08-18 15:26:40 EDT
I have logged the blocking bug 355150 against jst.jee, since we rely on their ModelProviderManager to get the web model, and it is being provided without content of the web.xml in the second web root. Note the "Deployment Descriptor" explorer node on opening the project (even before adding the JSF facet) - it shows no content, implying there are issues with the provider understanding multiple web roots.
Comment 4 Ian Trimble CLA 2011-08-24 14:44:08 EDT
Fix committed to 3.2.5 stream at 2011/08/24 11:36AM PDT.

See bug 355150 (and the bug it refers to) to understand the recent change made by the jst.jee team so that their subsystem more accurately tracks the "default" web root folder.

In a nutshell, along with the changes made to the JSF facet install delegate, your project needs to have its .component file tweaked slightly; on the web root you consider default (i.e. where you have your existing web.xml file), you need to add the attribute "tag", with the value "defaultRootSource".

That is, your .component file needs to change from what is in the attached sample project to the following:

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

The JSF Facet install delegate will then be handed a populated (instead of empty) model, and will be able to recognize this and act appropriately.
Comment 5 Ian Trimble CLA 2011-08-24 15:19:37 EDT
Fix committed to HEAD (3.3.1 and 3.4.0) stream at 2011/08/24 12:18PM PDT.
Comment 6 Raghunathan Srinivasan CLA 2011-08-26 13:07:02 EDT
Fix released to 3.2.5, 3.3.1 and 3.4.0 streams.