Bug 259685 - Bogus build error "Cannot nest" xyz "inside library"
Summary: Bogus build error "Cannot nest" xyz "inside library"
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 critical (vote)
Target Milestone: 3.5 M5   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-25 18:03 EST by Adalbert Homa CLA
Modified: 2009-01-27 13:43 EST (History)
2 users (show)

See Also:


Attachments
Screenshots of each step (707.13 KB, application/octet-stream)
2009-01-05 14:35 EST, Adalbert Homa CLA
no flags Details
Classpath generated from manifest file (242.09 KB, image/jpeg)
2009-01-07 09:23 EST, Adalbert Homa CLA
no flags Details
weblogic.jar manifest file (1.04 KB, application/octet-stream)
2009-01-09 08:06 EST, Adalbert Homa CLA
no flags Details
jar to reproduce the problem (285 bytes, application/x-jar)
2009-01-14 04:08 EST, Jerome Lanneluc CLA
no flags Details
Regression test (1.80 KB, patch)
2009-01-14 04:40 EST, Jerome Lanneluc CLA
no flags Details | Diff
Proposed fix (5.23 KB, patch)
2009-01-15 07:09 EST, Jerome Lanneluc CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adalbert Homa CLA 2008-12-25 18:03:59 EST
Build ID: I20081211-1908

Steps To Reproduce:
I received this error with a project that was working perfectly fine in previous versions of Eclipse (3.4).
I am using Weblogic 9.2 which has a library directory with a number of jar files and subdirectories with other jar files.

To reproduce this error I created a class path variable WEBLOGIC_HOME set to: c:/bea/weblogic92/ 
(Weblogic installed to default directory).

1. Create new Java project
2. Try to add library weblogic.jar (found in server/lib/)
3. Got error Description	Resource	Path	Location	Type
Cannot nest 
'C:bea/weblogic92/server/lib/ant/ant-juni' inside library 'C:bea/weblogic92/server/lib/ant/'	test		Build path	Build Path Problem






More information:
Comment 1 Jerome Lanneluc CLA 2009-01-05 11:05:02 EST
I cannot reproduce the problem. Please give more details on how to reproduce (starting from a fresh workspace).
Comment 2 Adalbert Homa CLA 2009-01-05 14:34:30 EST
(In reply to comment #1)
> I cannot reproduce the problem. Please give more details on how to reproduce
> (starting from a fresh workspace).
> 

I did provided all relevant information. Let me reiterate. I am attaching  screenshots of all of this
1. Download Weblogic 9.2 and install it into the default directory (c:/bea/weblogic92)
2. Run Eclipse 3.5M4 with an new empty workspace.
3. Create a Java project.
4. Create a variable WEBLOGIC_SERVER_LIB pointing to c:/bea/weblogic9.2/server/lib
5. Goto properties of the Java project
6. Add weblogic.jar from the WEBLOGIC_SERVER_LIB directory.
7. See the error which prevents adding the library to the project.

If you add the jar by modifying manually the .classpath file you got a build error.

Once again this worked fine in the previous version of Eclipse.
See the zip attachment with the screenshots. The first screenshots shows the content of the lib directory. The lib directory has a subdirectory with another list of jar files.

I checked the MANIFEST.MF file from the weblogic.jar. The classpath parameter has references to other jar files (ant/ant.jar and so on)


Comment 3 Adalbert Homa CLA 2009-01-05 14:35:26 EST
Created attachment 121554 [details]
Screenshots of each step
Comment 4 Adalbert Homa CLA 2009-01-05 14:37:21 EST
I think the MANIFEST.MF file is the one triggering this bug. 
If I add the file as an external jar there is no problem, only when it is added using a classpath variable.

Thanks
 
Comment 5 Jerome Lanneluc CLA 2009-01-06 04:38:50 EST
I don't have access to Weblogic (for legal reasons). Could you please create a small jar with a MANIFEST.MF that reproduces the problem?
Comment 6 Adalbert Homa CLA 2009-01-06 09:15:11 EST
(In reply to comment #5)
> I don't have access to Weblogic (for legal reasons). Could you please create a
> small jar with a MANIFEST.MF that reproduces the problem?
> 

It is free to download.
Comment 7 Adalbert Homa CLA 2009-01-07 09:21:55 EST
I think I found the problem and a workaround.
Starting with version 3.5 adding a JAR to the classpath of a Java project will also add any library present in the MANIFEST.MF.

The Class-Path parameter in the MANIFEST.MF file describes extension libraries that should be put into the classpath when running the jar. This classpath will be built recursively. However I do not think Eclipse should use for compilation.

I can not speak for everybody, but most developers are very careful in putting together the classpath.

In my case what seems to happening is the Eclipse reads the manifest file from weblogic.jar then from the referred jars. It ends in a circular pattern. See the attached screen shot.

Now we can debate that Weblogic jar files have the wrong manifest file, but the manifest file should not be used for compilation purpose only for running.

I also find that the manifest file in Weblogic has newlines in the Class-Path parameter and I don't think that is right. However weblogic works fine so very likely java can read the manifest file fine.

I could not find a compilation option that clearly states how this works in Eclipse. I found one option that seems to help. If I change the option "Incomplete build path" from Error to Warning then project no longer has build error.


I think this new feature could cause serious problems to a lot of developers. Eclipse should have a clearly labeled option by default to set to false to check or not the manifest file in the jar.

Comment 8 Adalbert Homa CLA 2009-01-07 09:23:33 EST
Created attachment 121807 [details]
Classpath generated from manifest file
Comment 9 Jerome Lanneluc CLA 2009-01-09 07:01:04 EST
This feature was asked in bug 198572.

However I agree that errors should not be reported because of the Class-Path parameter in the MANIFEST.MF.

Could you please attach the MANIFEST.MF so that we understand what's causing the error to be reported?
Comment 10 Adalbert Homa CLA 2009-01-09 08:05:32 EST
(In reply to comment #9)

I am attaching the manifest file from weblogic.jar.
I read the history of this bug. Interesting that it was raised originally because of Weblogic, but exactly that one does not work.

I checked other manifest files in the Weblogic jar files and they all suffer the wrapping problem.
 
Comment 11 Adalbert Homa CLA 2009-01-09 08:06:05 EST
Created attachment 122099 [details]
weblogic.jar manifest file
Comment 12 Jerome Lanneluc CLA 2009-01-14 04:08:39 EST
Created attachment 122511 [details]
jar to reproduce the problem

To reproduce:
1. New Java project
2. Add the attached jar as an external library
Observe: You get a build path problem: Cannot nest 'D:temp/lib/sublib/' inside library 'D:temp/lib/'
Comment 13 Jerome Lanneluc CLA 2009-01-14 04:40:18 EST
Created attachment 122513 [details]
Regression test
Comment 14 Philipe Mulet CLA 2009-01-14 07:47:33 EST
Should there be an option or classpath attribute to allow disabling the JAR chaining ?
Comment 15 Philipe Mulet CLA 2009-01-14 07:48:36 EST
I actually meant:

Should there ALSO be an option or classpath attribute to allow disabling the JAR
chaining ? (in addition to addressing this bug)
Comment 16 Jerome Lanneluc CLA 2009-01-14 08:32:15 EST
If we introduced this option, it would only be to workaround bugs such as this one. So I think this option should be a system property and not a user preference.
Comment 17 Jerome Lanneluc CLA 2009-01-15 07:09:11 EST
Created attachment 122658 [details]
Proposed fix
Comment 18 Jerome Lanneluc CLA 2009-01-15 09:21:35 EST
Fix and test released for 3.5M5
Comment 19 Srikanth Sankaran CLA 2009-01-27 04:04:18 EST
Verified for 3.5M5 using I20090125-2000 build