Bug 279360 - Libraries from classpath containers aren't deployed if j2ee project structure is a single root structure
Summary: Libraries from classpath containers aren't deployed if j2ee project structur...
Status: RESOLVED FIXED
Alias: None
Product: WTP Java EE Tools
Classification: WebTools
Component: jst.j2ee (show other bugs)
Version: 3.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.2   Edit
Assignee: Jason Peterson CLA
QA Contact: Chuck Bridgham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-06 16:46 EDT by Snjezana Peco CLA
Modified: 2010-04-02 06:03 EDT (History)
4 users (show)

See Also:


Attachments
a patch (1.08 KB, patch)
2009-06-06 16:47 EDT, Snjezana Peco CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Snjezana Peco CLA 2009-06-06 16:46:17 EDT
Build ID: I20090528-2000

Steps To Reproduce:
1. create a dynamic Web Project
2. set "WebContent/WEB-INF/classes" as Java output folder
3. add a classpath container (user library, for instance) to the Java classpath of the project
4. add the classpath container to the project using the Java EE Module dependencies preference page
5. deploy the project to some server
6. no one library from the container created in step 4 is deployed



More information:
J2EEFlexProjDeployable.isSingleRootStructure() returns true for this project; the members method skips adding libraries from a classpath container.

Attached is a patch.

A workaround is to change the Java output folder, open, close and redeploy the project
Comment 1 Snjezana Peco CLA 2009-06-06 16:47:32 EDT
Created attachment 138492 [details]
a patch
Comment 2 Max Rydahl Andersen CLA 2009-06-07 12:09:22 EDT
Note: this is easy to bump into if you use tools like m2eclipse or ivy which uses classpath containers to provide libraries.
Comment 3 Tim deBoer CLA 2009-06-08 11:31:46 EDT
Moving to JEE team, believe this might be a dup.
Comment 4 Carl Anderson CLA 2009-06-08 17:22:52 EDT
I think this is related to bug 249044 - assigning it to Jason Sholl for initial investigation.
Comment 5 Rob Stryker CLA 2009-06-08 23:03:24 EDT
This was mentioned in Bug 277482  but had not been given its own bug ID yet. 


> 5) You can add classpath variable entries.... however if I made a 
> variable that pointed directly to /home/rob/tmp/some2.jar, and apply 
> the change, the following gets added to the component xml file:
>
> <dependent-module deploy-path="/"
>             handle="module:/classpath/var/some2">
> <dependency-type>uses</dependency-type>
>
> But upon a publish this file is not included. Upon an export, this 
> file *is* included, but it's name is "some2" and it lacks a file 
> extension.

Therefore I don't believe Snjezana's patch is complete as it only addresses the publish instance and not the export. 
Comment 6 Snjezana Peco CLA 2009-06-09 06:08:45 EDT
> Therefore I don't believe Snjezana's patch is complete as it only addresses the
publish instance and not the export.

The problem that I described doesn't happen when exporting.



Comment 7 Rob Stryker CLA 2009-06-17 09:01:21 EDT
I like Snjezana's patch as it looks like it would work properly... however, better question is should isSingleRootStructure return true at all if there are references? 

javadoc says the following:

	 * In a single root structure, all files that are contained within the root folder
	 * are part of the module, and are already in the correct module structure. No
	 * module resources exist outside of this single folder.

The key part being "No module resources exist outside of this single folder". So is a project with classpath / var / lib references outside the project "single root" ?
Comment 8 Rob Stryker CLA 2009-06-22 05:47:47 EDT
After finding some more comments, I don't think this patch is the right way to go. isSingleRootStructure() must be modified to check for virtual component variable references.

Note the comments below

	/**
	 * This method is added for performance reasons. It can ONLY be called when the project is single root.
	 * @see isSingleRootStructure().  If the project has an output folder that is also a source folder then,
	 * it assumes the virtual component is not using any flexible features and is in a standard J2EE format
	 * with one component root folder and an output folder the same as its content folder.  This will bypass 
	 * the virtual component API and just return the module resources as they are on disk.
	 * 
	 * @return array of ModuleResources
	 * @throws CoreException
	 */
	private IModuleResource[] getOptimizedMembers() throws CoreException {
		if (component != null) {
			if (isSingleJavaOutputNonSource) {
				// We determined when testing for a single root structure that this project has
				// one output folder and that output folder is not a source folder. Since the
				// output folder (for example, classes or bin) is not a source folder, JDT copies all files
				// (including non Java files) to this folder, so every resource needed at runtime is located 
				// in that single output directory.
				return getModuleResources(Path.EMPTY, getJavaOutputFolders()[0]);
			}
			// For J2EE modules, we use the contents of the content root
			else {
				IVirtualFolder vFolder = component.getRootFolder();
				return getModuleResources(Path.EMPTY, vFolder.getUnderlyingFolder());
			}
		}
		return new IModuleResource[] {};
	}


I would conjecture that if there are any references to external jars, then it is *not* in the single root structure. 
Comment 9 Carl Anderson CLA 2009-09-02 23:25:57 EDT
We're going to be addressing isSingleRoot() in WTP 3.2, and will back-port as much as possible to 3.1.2.
Comment 10 Carl Anderson CLA 2010-02-04 02:17:13 EST
Snjezana, a lot of work has been done in this area for WTP 3.2... is this still a problem?
Comment 11 Jason Peterson CLA 2010-03-31 14:18:14 EDT
In response to comment number 5 the reason this was not working for export is because you needed to extend the variable.  

It was not working for deploy because we never computed the variable and external jar entries for a single root project.  However, I recently addressed in issue with this in bug 306534 and now variables and external jars will be returned as child modules as long as they qualify.  However, it is up to server tools to get these child modules and process them properly.  Not sure if this is happening in all cases.  Classpath containers, which get added into the classpath file with the dependency attribute, are now checked in the single root util.  If found it now returns false.
Comment 12 Rob Stryker CLA 2010-04-02 06:03:22 EDT
(In reply to comment #11)
> In response to comment number 5 the reason this was not working for export is
> because you needed to extend the variable.  

You do not, and should not, need to extend a variable which references a jar. If the variable references a folder, then of course you need to extend it. However if the variable just references a single jar, it doesn't need to be extended. In comment 5, I believe it was just against a jar (like rt.jar or something). 

So lets just make sure thats a tested usecase too ;)