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

Bug 311079

Summary: The "Serve Modules Without Publishing" option should support "META-INF/resources" for Tomcat 7
Product: [WebTools] WTP ServerTools Reporter: Larry Isaacs <larryisaacs>
Component: jst.serverAssignee: Larry Isaacs <larryisaacs>
Status: CLOSED FIXED QA Contact: Angel Vera <arvera>
Severity: major    
Priority: P3 CC: david_williams
Version: 3.2Flags: david_williams: pmc_approved+
arvera: pmc_approved? (raghunathan.srinivasan)
arvera: pmc_approved? (naci.dai)
arvera: pmc_approved? (deboer)
arvera: pmc_approved? (neil.hauge)
arvera: pmc_approved? (kaloyan)
arvera: review+
Target Milestone: 3.2 RC1   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/108949
Whiteboard: PMC_approved
Attachments:
Description Flags
Patch to support serving content from META-INF/resources in dependent projects none

Description Larry Isaacs CLA 2010-04-29 13:59:54 EDT
The current implementation for the "Serve Modules Without Publishing" fails to automatically include a "META-INF/resources" folder in the list of "extraResourcePaths" if present in a dependent web fragment project.  The "META-INF/resources" folder in web fragments is a Servlet 3.0 feature that allows static content to be contributed to the host web application.
Comment 1 Larry Isaacs CLA 2010-05-11 13:56:34 EDT
Created attachment 167989 [details]
Patch to support serving content from META-INF/resources in dependent projects
Comment 2 Larry Isaacs CLA 2010-05-11 14:32:41 EDT
Angel,

I feel this would be valuable to get into RC1.  The required details follow.


* Explain why you believe this is a stop-ship defect.

The "Serve Modules Without Publishing" option is a useful feature of the Tomcat server adapter.  The Servlet 3.0 feature of placing content resources in the "META-INF/resources" folder of jars in the "WEB-INF/lib" of web applications stops working when this option is enabled for Tomcat 7.  This applies to dependent projects of the dynamic web projects, which may contain a "META-INF/resources" folder in some form.

* Is there a work-around? If so, why do you believe the work-around is insufficient? 
There is no workaround other than not using the "Serve Modules Without Publishing" when this Servlet 3.0 feature is desired.

* How has the fix been tested? Is there a test case attached to the bugzilla record? Has a JUnit Test been added?

I have verified that for a Web Fragment project with a ".component" file containing:

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="WebFragment30">
        <wb-resource deploy-path="/" source-path="/src"/>
        <wb-resource deploy-path="/" source-path="/WebContent"/>
        <wb-resource deploy-path="/META-INF" source-path="/WebContent2"/>
        <wb-resource deploy-path="/META-INF/resources" source-path="/WebContent3"/>
        <wb-resource deploy-path="/META-INF/resources/subfolder" source-path="/WebContent4"/>
    </wb-module>
</project-modules>

that JSPs in each of the "WebContent" folders continues to be served correctly after "Serve Modules Without Publishing" is enabled for a Tomcat 7 server.  Also, JSPs in under a "/src/META-INF/resources" folder in the project also continue to be served correctly.  FYI: I've found this area of the code somewhat challenging to understand fully.  I'll be glad to answer any questions that arise about the patch.

* Give a brief technical overview. Who has reviewed this fix?

The patch builds upon the support for multiple "WebContent" folders added in M7.  For dependent projects of a dynamic web project, folder mappings that could contribute a "META-INF/resources" folder need to be checked to see if such a folder is actually present, and if found, added to the list of "WebContent" folders being served provided the server is Tomcat 7.

* What is the risk associated with this fix?

Minimal.  The changes affects only an isolated feature of the Tomcat server adapter, and alters behavior in a limited code path.  I'm not an expert of the Servlet 3.0 spec enough to say with certainty that I've covered all possible use cases that the "Serve Modules Without Publishing" option needs to handle, but I think we are better off covering this use case than not covering it.
Comment 3 Angel Vera CLA 2010-05-11 16:38:13 EDT
Approved
Comment 4 Larry Isaacs CLA 2010-05-12 10:25:46 EDT
Changes released to HEAD.
Comment 5 Larry Isaacs CLA 2010-05-14 13:10:58 EDT
Verified "META-INF/Resources" static content is working with the "Serve Module Without Publishing" option using WTP S-3.2.0RC1-20100513125036 build.

It should be noted that though the "META-INF/resources" content is being served, the order in which these folder are searched within multiple dependant projects may not be Servlet 3.0 spec compliant.  This means that which one of duplicate resources is served may be incorrect when "Serve Module Without Publishing" is enabled.  Assuming Bug 312920 gets fixed, then it is likely that "META-INF/resources" found under the "src" folder of the dependant projects will be searched in the Servlet 3.0 spec compliant order.
Comment 6 Larry Isaacs CLA 2010-05-14 13:11:10 EDT
Closing.
Comment 7 Eclipse Genie CLA 2017-10-11 16:33:27 EDT
New Gerrit change created: https://git.eclipse.org/r/108949