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

Bug 285722

Summary: Running Tomcat with 'Serve Modules Without Publishing' option and multiple wb-resource deploy-path
Product: [WebTools] WTP ServerTools Reporter: Matteo TURRA <m.turra>
Component: jst.serverAssignee: Larry Isaacs <larryisaacs>
Status: RESOLVED FIXED QA Contact: Angel Vera <arvera>
Severity: enhancement    
Priority: P3 CC: ccc, enrico.bottacin01, f.munafo, stryker, thatnitind
Version: 3.1Keywords: plan
Target Milestone: 3.2 M6   
Hardware: PC   
OS: Windows Server 2003   
See Also: https://git.eclipse.org/r/108867
Whiteboard:
Attachments:
Description Flags
Eclipse Web Resuorces
none
Patch to add a webResource attribute to element Resources of server.xml
none
Patch to WtpDirContext to lookup the additional web Resourses
none
Patch to WtpDirContext to lookup the additional web Resourses
none
Patch to WtpDirContext to lookup the additional web Resourses none

Description Matteo TURRA CLA 2009-08-05 12:09:30 EDT
Build ID: 20090621-0832

Steps To Reproduce:
1. Create a Dynamic Web Project
2. Add a folder on the root of the project (i.e. WebContent2)
3. Modify the org.eclipse.wst.common.component adding a second line under 
<wb-resource deploy-path="/" source-path="/WebContent"/>
like that
<wb-resource deploy-path="/" source-path="/WebContent2"/> 
4. Running without the 'Serve Modules Without Publishing' option the content of WebContent2 is published. Running with the 'Serve Modules Without Publishing' option only the content in WebContent is reachable from tomcat. 


More information:
Comment 1 Angel Vera CLA 2009-08-05 13:14:02 EDT
Is this something that the JEE support and will pick up during the members() call?
Comment 2 Matteo TURRA CLA 2009-08-10 04:49:47 EDT
Created attachment 143872 [details]
Eclipse Web Resuorces
Comment 3 Matteo TURRA CLA 2009-08-10 05:09:15 EDT
Created attachment 143874 [details]
Patch to add a webResource attribute to element Resources of server.xml

This is the patch to add the attribute webResources to Resources element in the server.xml created when "serve without publishing" is used.
Comment 4 Matteo TURRA CLA 2009-08-10 05:24:00 EDT
Created attachment 143875 [details]
Patch to WtpDirContext to lookup the additional web Resourses

This is the patch to the WtpDirContext class. If a resource is not found in the base root, it look up in the other web resources.
Comment 5 Matteo TURRA CLA 2009-08-10 05:24:14 EDT
Created attachment 143876 [details]
Patch to WtpDirContext to lookup the additional web Resourses

This is the patch to the WtpDirContext class. If a resource is not found in the base root, it look up in the other web resources.
Comment 6 Matteo TURRA CLA 2009-08-10 05:24:25 EDT
Created attachment 143877 [details]
Patch to WtpDirContext to lookup the additional web Resourses

This is the patch to the WtpDirContext class. If a resource is not found in the base root, it look up in the other web resources.
Comment 7 Matteo TURRA CLA 2009-08-10 05:27:44 EDT
Comment on attachment 143876 [details]
Patch to WtpDirContext to lookup the additional web Resourses

sorry
Comment 8 Matteo TURRA CLA 2009-08-10 05:29:56 EDT
Comment on attachment 143875 [details]
Patch to WtpDirContext to lookup the additional web Resourses

Correct mime type and patch flg
Comment 9 Matteo TURRA CLA 2009-08-10 05:35:58 EDT
I add two patches to org.eclipse.jst.server.tomcat plugin.
The first one is used to write an addition attribute in the Resource element of server.xml, called webResources.

The second is to let tomcat search in this web resources if nothing is found in the doc base.
Comment 10 Rob Stryker CLA 2009-09-02 16:26:47 EDT
Angel:

In response to Comment 1, no. The jee team will not change the results of a member() call depending on if it's single root or not. isSingleRoot() is now just a flag and hte server adapter can do whatever optimizations they want at that point.
Comment 11 Angel Vera CLA 2009-09-02 16:38:15 EDT
(In reply to comment #10)
Agreed, but it was my understanding that there were some problems with some optimization code that JEE was doing, which might already be fixed. I thought this problem might be related to that, but it sounds like the members is returning the full set of files, and in this case there is some missing functionality in tomcat. 

Passing down to Larry, to asses if this non-single root modules is something that Tomcat can add to its code. But I doubt this is something they can add to 3.1.1, I am leaving the target as 3.1.1 for now, but Larry please asses if this is new functionality (as it sounds like it is).
Comment 12 Rob Stryker CLA 2009-09-02 16:44:04 EDT
I did a quick test and 3.1.1 was not mis-identifying this object as single root. The tools correctly realize it is not single root and return all resources =]
Comment 13 Larry Isaacs CLA 2009-09-03 09:13:12 EDT
This is a known limitation of the "Serve modules without publishing" feature since it was introduced in WTP 2.0.x, so I'm changing this report to an enhancement.  The default implmentation in Tomcat only supports a single "docBase".  For this use case, Tomcat support for multiple "docBase"s is needed.  The attached patches seem to be a good approach to address this, so I'll see about working something into WTP 3.2.  This represents too big a change to include in WTP 3.1.x.
Comment 14 Matteo TURRA CLA 2010-02-05 11:52:51 EST
Larry, will my patch commited on wtp 3.2 release?
Do you need something else?
Thanks.
Comment 15 Larry Isaacs CLA 2010-02-06 10:17:37 EST
It is my goal to add this support in M6.  I'm using your work (thanks!) as a starting point, but I'm reworking it to support mapping the  additional resources to something other than "/".  The WTP changes are done, now it's a matter of implementing the Tomcat side for 5.0, 5.5, 6.0, and maybe 7.0.
Comment 16 Larry Isaacs CLA 2010-03-12 14:19:18 EST
This support is present in WTP 3.2M6.  It should handle most any mapping you can add with the new UI.

The one thing that is *not* supported is mapping a *content* folder to "/WEB-INF/classes".  A mapping to "/WEB-INF/classes" is assumed to be associated with a Java source folder, not a content folder.  Any *content* folder mapped to "/WEB-INF/classes" will be ignored.

You can however, map a content folder to "/WEB-INF".  If this content folder contains a "classes" subfolder, the effective "WEB-INF/classes" will get included in the webapp classloader's classpath in addition to being included in the list of "docBases" to search for resources.  Also, if you map a folder to "/WEB-INF/lib", or map a folder that contains a "lib" subfolder to "/WEB-INF", any jars present in the effective "WEB-INF/lib" will also be included in the webapp classloader's classpath.

Note that when 'Serve Modules Without Publishing' is enabled, tag files in utility projects won't work in Tomcat 6.0.18 through 6.0.26.  See Tomcat bug https://issues.apache.org/bugzilla/show_bug.cgi?id=48737 for details.  This issue should be fixed in the next release of Tomcat 6.0.x.

Adding the "plan" keyword to add a little more visibility to this enhancement beyond the mention in the M6 New and Noteworthy, which I will add soon.
Comment 17 Eclipse Genie CLA 2017-10-11 16:31:15 EDT
New Gerrit change created: https://git.eclipse.org/r/108867