Bug 201062 - Missing library in project classpath even library exists
Summary: Missing library in project classpath even library exists
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M2   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-24 06:03 EDT by Christian Spiegel CLA
Modified: 2007-09-18 08:41 EDT (History)
2 users (show)

See Also:


Attachments
Possible fix (15.23 KB, patch)
2007-08-30 10:53 EDT, 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 Christian Spiegel CLA 2007-08-24 06:03:58 EDT
Build ID: Eclipse 3.3.0 I20070621-1340

Steps To Reproduce:
1.Simple java project with a library in classpath: combined from classpath variable and path to a network share
2.Open eclipse workspace without connection to network share with the library defined in projects build path
3.Project problem: Missing required library occurs (expected)
4.Close eclipse workspace und reconnect to network share
5.Start eclipse workspace
6.The mentioned error still occurs


More information:
The problem can't solved by clean or refresh the project. I've found two solutions (workarounds):
1. Add a new library to build path of the project which is stored on the same network share forces a update of the classpath and the error disappears.

2. Rename the classpath variable. Rebuild essential. Rename the classpath variable back to the further name und rebuild again. The classpath is updated correctly.

Solution 2 works even if the classpath variable is used in more than one project.
Comment 1 Jerome Lanneluc CLA 2007-08-27 05:12:04 EDT
Have you tried File > Refresh in the Java perspective ?
Comment 2 Christian Spiegel CLA 2007-08-27 05:20:58 EDT
Yes I did. Neither Refresh or a project clean does invoke a classpath update.
Comment 3 Jerome Lanneluc CLA 2007-08-27 09:32:45 EDT
I was able to reproduce with the following steps:
1. Start new workspace
2. Create new Java project with d:\temp\test\mylib.jar on the build path
3. Exit
4. Rename d:\temp\test into d:\temp\test.old
5. Restart
Observe: A classpath marker shows a build path problem
6. Rename d:\temp\test.old into d:\temp\test
7. Select the Java project and refresh
Observe: The classpath marker is still present (even if the jar appears in the Package Explorer

Note that this must be a timing issue, as attempting to follow those steps running under the debugger failed to reproduce the bug.

Investigating...
Comment 4 Jerome Lanneluc CLA 2007-08-29 04:29:33 EDT
Actually steps from comment 3 won't show the problem every time. It sounds like a timing issue. Need to further investigate by looking at the code.
Comment 5 Jerome Lanneluc CLA 2007-08-30 10:53:40 EDT
Created attachment 77382 [details]
Possible fix

I was never able to consistently reproduce the problem, but looking at the code, it looks like the work we do to refresh external jars on each auto-build job POST_CHANGE is interfering concurrently with the computing of external jars delta. As a result, the delta is computed and the external  timestamps are updated, but the classpath validation is not done. Further refreshes do nothing since the timestamps are up-to-date.

The fix consisted in avoiding this concurrency problem by moving the code elements to refresh on the delta state, and by not doing the refresh on each POST_CHANGE. As a consequence, a full build is not going to refresh the external jar, but as this bug shows this didn't work properly already. Only a refresh will now update the external jars.

Note that this patch doesn't contain a regression test as this a timing problem. And the test that assumed that a full build would refresh the external jars has been removed.
Comment 6 Jerome Lanneluc CLA 2007-08-31 03:35:49 EDT
Fix released for 3.4M2 in HEAD.
Comment 7 Christian Spiegel CLA 2007-09-04 07:48:29 EDT
Is there a patch planed for eclipse 3.3?
Comment 8 Jerome Lanneluc CLA 2007-09-04 10:25:53 EDT
The fix is not obvious, and we need to test it extensively in the 3.4 stream before we decide to backport it to 3.3.x.

Note in addition to the workarounds you proposed, another workaround is to close/reopen the project when this happens.
Comment 9 Christian Spiegel CLA 2007-09-04 10:53:29 EDT
Close and Reopen does not solve the problem. The error that the libraries are missing disappears but the error that a build paths error occures is still present.
Comment 10 Jerome Lanneluc CLA 2007-09-04 10:58:30 EDT
Sorry I was not clear enough. After close/reopen you need to rebuild (might need a Project > Clean first)
Comment 11 Frederic Fusier CLA 2007-09-18 08:41:02 EDT
Verified for 3.4 M2 using I20070917-0010.