Bug 250946 - Bogus jar file is added to the project build path
Summary: Bogus jar file is added to the project build path
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: All All
: P3 blocker (vote)
Target Milestone: 3.5 M3   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 250973 (view as bug list)
Depends on:
Blocks: 252264
  Show dependency tree
 
Reported: 2008-10-15 10:29 EDT by Pascal Rapicault CLA
Modified: 2008-12-10 12:24 EST (History)
10 users (show)

See Also:


Attachments
Proposed fix and regression test (8.57 KB, patch)
2008-10-16 05:18 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 Pascal Rapicault CLA 2008-10-15 10:29:16 EDT
I20081014
The PDE project is looking for the wrong jar file on disk which cause the project to fail compiling.
Steps to reproduce:
- load org.eclipse.equinox.p2.director project from the RT repository (/cvsroot/rt). The project is located under org.eclipse.equinox/p2/bundles.
- compile and notice the compile error, you will see that it is looking for a file called org.sat4j.core.jar whereas the file on disk is org.sat4j.core_v....jar
Comment 1 Chris Aniszczyk CLA 2008-10-15 10:57:59 EDT
Any idea when this started to happen?

I just traced through PDE code and it's added things properly to the classpath.

/Users/chrisaniszczyk/eclipses/eclipse-SDK-3.5M3/eclipse/plugins/org.sat4j.core_2.0.0.v20080602.jar[CPE_LIBRARY][K_BINARY][sourcePath:/Users/chrisaniszczyk/eclipses/eclipse-SDK-3.5M3/eclipse/plugins/org.sat4j.core_2.0.0.v20080602.jar][isExported:false][AccessRuleSet {pattern=org/sat4j/* (ACCESSIBLE), pattern=org/sat4j/core/* (ACCESSIBLE), pattern=org/sat4j/minisat/* (ACCESSIBLE), pattern=org/sat4j/minisat/constraints/* (ACCESSIBLE), pattern=org/sat4j/minisat/constraints/card/* (ACCESSIBLE), pattern=org/sat4j/minisat/constraints/cnf/* (ACCESSIBLE), pattern=org/sat4j/minisat/core/* (ACCESSIBLE), pattern=org/sat4j/minisat/learning/* (ACCESSIBLE), pattern=org/sat4j/minisat/orders/* (ACCESSIBLE), pattern=org/sat4j/minisat/restarts/* (ACCESSIBLE), pattern=org/sat4j/minisat/uip/* (ACCESSIBLE), pattern=org/sat4j/opt/* (ACCESSIBLE), pattern=org/sat4j/reader/* (ACCESSIBLE), pattern=org/sat4j/specs/* (ACCESSIBLE), pattern=org/sat4j/tools/* (ACCESSIBLE), pattern=**/* (NON ACCESSIBLE | IGNORE IF BETTER)} [classpath entry: /Users/chrisaniszczyk/eclipses/eclipse-SDK-3.5M3/eclipse/plugins/org.sat4j.core_2.0.0.v20080602.jar]]

debugging JDT code...
Comment 2 Chris Aniszczyk CLA 2008-10-15 11:06:06 EDT
figured it out.

org.sat4j.pb has this header:

Class-Path: org.sat4j.core.jar

JavaProject, line 2577

// resolve Class-Path: in manifest
ClasspathEntry[] extraEntries = cEntry.resolvedChainedLibraries();
   for (int k = 0, length2 = extraEntries.length; k < length2; k++) {
      addToResult(rawEntry, extraEntries[k], result, resolvedEntries, externalFoldersManager);
   }

That line is adding 'org.sat4j.core.jar' to the build path based on the Class-Path entry in the MANIFEST.MF of org.sat4j.pb.

If that header is removed, I think we'll be fine. I think JDT needs to be more careful when adding these types of entries.
Comment 3 Olivier Thomann CLA 2008-10-15 11:06:47 EDT
It works in one of my workspace, but it fails in a fresh new workspace.
Comment 4 Olivier Thomann CLA 2008-10-15 11:09:22 EDT
Moving to JDT/Core.
Comment 5 Paul Webster CLA 2008-10-15 14:56:15 EDT
bug 250973 is probably a dup then.

PW
Comment 6 Daniel Le Berre CLA 2008-10-15 15:40:33 EDT
Shouldn't classpath be only related to OSGi declarations for OSGi bundles?

I use the Class-Path entry for auto-executable jars.

That way, the same jar can be used as OSGi bundles and as command line tools.
Comment 7 Jerome Lanneluc CLA 2008-10-15 16:43:10 EDT
*** Bug 250973 has been marked as a duplicate of this bug. ***
Comment 8 Jerome Lanneluc CLA 2008-10-15 16:55:33 EDT
To summarize the issue, a build path problem is reported because a plugin contains a bogus reference in its MANIFEST.MF's Class-Path:

I will make sure that we don't report such problem in the future. In the meantime, a workaround is to set "Preferences > Compiler > Building > Build path problems > Incomplete build path" to Warning.
Comment 9 Daniel Le Berre CLA 2008-10-15 17:54:29 EDT
Jerome,

Am I supposed to either remove the Class-Path: entry or to fill it with the jar file using Eclipse naming convention for the next release of SAT4J?
Comment 10 Jerome Lanneluc CLA 2008-10-16 04:07:05 EDT
(In reply to comment #9)
> Jerome,
> 
> Am I supposed to either remove the Class-Path: entry or to fill it with the jar
> file using Eclipse naming convention for the next release of SAT4J?
> 
Daniel, I would say that using Eclipse naming convention would be better. However I'm wondering why the Class-Path: is simply there. Is it used at runtime? If it is, how can this works since the referenced jar doesn't exist? Do you look up a jar with a similar name at runtime?
Comment 11 Jerome Lanneluc CLA 2008-10-16 05:18:28 EDT
Created attachment 115233 [details]
Proposed fix and regression test
Comment 12 Daniel Le Berre CLA 2008-10-16 05:29:22 EDT
Jerome,

The Class-Path entry is there because some (me included :)) users of SAT4J use it from the command line and I would like to use the same jar files for my OSGi bundles and my auto-executable jar files.

The two packages that ship with Eclipse contain the Pseudo Boolean solvers that take an input file and display a solution according to the guidelines in http://www.cril.univ-artois.fr/PB07/

When I build the jar files, they are named org.sat4j.core.jar and org.sat4j.pb.jar to make life easier for command line users.

Pascal renames the jar files according to Eclipse guidelines before integration into Orbit.

Until now, it did not cause any trouble since Eclipse was only relying on the OSGi information available in the manifest file.

If this is a wrong practice, I will simply generate the jar files using Eclipse guidelines and fix the Class-Path entry to make it consistent with the bundle names.

Comment 13 Jerome Lanneluc CLA 2008-10-16 06:39:10 EDT
(In reply to comment #12)
Thanks for the explanation Daniel. I think I now understand:
org.sat4j.pb has 2 ways to define its dependency to org.sat4j.core. The Require-Bundle: entry and the Class-Path: entry. The first one is used by PDE at compile time and OSGI at runtime. The second one is used by JDT at compile time and the VM at runtime. 

The problem is that JDT is not permissive enough and creates a build path marker if the jar referenced by the Class-Path: entry doesn't exit. 

One way to solve this would be for you to change the reference in the Class-Path: entry to a jar with a name that follows the Eclipse guideline (and thus this jar would exist).

The other way is for JDT to simply not create a build path marker. This is what the proposed fix from comment 11 does.

I will go with the latter solution since (as shown by 250973) other jars exist which assume that the Class-Path: entry is optional (i.e. that the jar may or may not exit).
Comment 14 Boris Bokowski CLA 2008-10-16 09:54:06 EDT
It looks like this bug is preventing us from compiling our workspaces when using an IBM JDK as the default JRE. (See also bug 251079 - is this related in any way?)

Are you planning to ask for a rebuild?
Comment 15 Jerome Lanneluc CLA 2008-10-16 10:02:38 EDT
(In reply to comment #14)
> It looks like this bug is preventing us from compiling our workspaces when
> using an IBM JDK as the default JRE. 
Are you saying that the workaround from comment 8 doesn't work for you?

> (See also bug 251079 - is this related in any way?)
I don't think this is related.

> Are you planning to ask for a rebuild?
Only if the workaround doesn't work.

Comment 16 Boris Bokowski CLA 2008-10-16 10:26:00 EDT
(In reply to comment #8)
> I will make sure that we don't report such problem in the future. In the
> meantime, a workaround is to set "Preferences > Compiler > Building > Build
> path problems > Incomplete build path" to Warning.

This workaround is not really an option for us since all these settings are project-specific. We'd have to go through all our projects, change this, check in the change, and then remember to undo it later.
Comment 17 Jerome Lanneluc CLA 2008-10-16 10:36:00 EDT
Fix and test released for 3.5M3.

I'm preparing the build input and I will ask for a rebuild when ready.
Comment 18 Jeff McAffer CLA 2008-10-16 10:40:19 EDT
If possible it would be much better for SAT4J come as real bundles rather than nesting the JAR inside.  This is the standard way we package and ship third party (see pretty much any Orbit bundle).  If the SAT4J team could produce such a bundle that would be fantastic.  If not, then we should package the provided JAR as a bundle using the Orbit conventions.  AFAIK there is nothing special about SAT4J that should demand special packaging.

While the issue in JDT may still be real and bear fixing, this is approach would both avoid the problem and help SAT4J follow the Eclipse best practices.
Comment 19 Thomas Watson CLA 2008-10-16 10:56:59 EDT
(In reply to comment #18)
> If possible it would be much better for SAT4J come as real bundles rather than
> nesting the JAR inside.  This is the standard way we package and ship third
> party (see pretty much any Orbit bundle).  If the SAT4J team could produce such
> a bundle that would be fantastic.  If not, then we should package the provided
> JAR as a bundle using the Orbit conventions.  AFAIK there is nothing special
> about SAT4J that should demand special packaging.
> 
> While the issue in JDT may still be real and bear fixing, this is approach
> would both avoid the problem and help SAT4J follow the Eclipse best practices.
> 

SAT4J is a real bundle, correct?  The issue is when using sat4j from the command line without OSGi:

java -jar org.sat4j.pb.jar

In this case the org.sat4j.core.jar is *not* embedded in the org.sat4j.pb.jar, instead it is in the same directory as the pb.jar and the VM adds the core.jar to the app classpath along with the pb.jar.  I imagine the SAT4J folks do not want to use the version of core down to the qualifier in their Class-Path header for the same reason we do not restrict Require-Bundle version ranges down to the qualifier.  It is too brittle.
Comment 20 Daniel Le Berre CLA 2008-10-16 11:06:01 EDT
Thomas, you are right.

That's exactly the problem.
Comment 21 Olivier Thomann CLA 2008-10-16 12:22:04 EDT
I verified that the fix is getting rid of both errors (the one from p2.director and the one from IBM JDK 6).
Comment 22 Olivier Thomann CLA 2008-10-27 16:12:23 EDT
The problem is no longer an error, but we should make the warning optional.
Setting up a project with an IBM 1.6.0 as the JRE leads too many warnings in the .log file each time the classpath is touched.
eclipse.buildId=I20081026-2000
java.version=1.6.0_10
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=fr_CA
Command-line arguments:  -os win32 -ws win32 -arch x86 -debug -consolelog -console


Warning
Mon Oct 27 16:10:56 EDT 2008
Invalid Class-Path header in manifest of jar file: D:\jdks\ibm1.6.0\jre\lib\ibmcfw.jar

Verified for 3.5M3 using I20081026-2000
Comment 23 Olivier Thomann CLA 2008-10-27 16:32:22 EDT
In some cases, I still get a build path error.
Comment 24 Olivier Thomann CLA 2008-10-28 10:26:51 EDT
*** Bug 252364 has been marked as a duplicate of this bug. ***
Comment 25 Jerome Lanneluc CLA 2008-10-28 11:24:53 EDT
(In reply to comment #23)
> In some cases, I still get a build path error.
This is tracked by bug 252392

Comment 26 Eric Moffatt CLA 2008-12-10 10:45:03 EST
I've just seen this in I20081210-0100 (the current M4 candidate).

All OK...then error spam. Clean/rebuild...no dice...shutdown/restart...no dice...Arghh!! Switched back to a previous install (I20081202-1812)..all OK.

I've also seen this in yesterday's build on my co-op's Workspace...

We're both using an IBM jre...
Comment 27 Eric Moffatt CLA 2008-12-10 10:58:35 EST
Mike Valenta just ran into this and switching to a Sun JRE solved it...
Comment 28 Olivier Thomann CLA 2008-12-10 11:24:22 EST
If there is still an issue with IBM VM, please reopen it and provide steps to reproduce.
Comment 29 Jerome Lanneluc CLA 2008-12-10 11:46:51 EST
(In reply to comment #26)
> I've just seen this in I20081210-0100 (the current M4 candidate).
Eric can you please clarify what "this" is? Note that comment 0 refers to the wrong org.sat4j.core.jar being looked up? Is this what you're seeing? If not please enter a separate bug report.
Comment 30 Jerome Lanneluc CLA 2008-12-10 11:47:34 EST
And do not reopen if it is a different issue than comment 0.
Comment 31 Olivier Thomann CLA 2008-12-10 12:17:26 EST
I think Eric is getting what I reported in comment 22.
Comment 32 Jerome Lanneluc CLA 2008-12-10 12:24:10 EST
(In reply to comment #31)
> I think Eric is getting what I reported in comment 22.
> 
Really? A warning in the log and this is reported as:
" All OK...then error spam. Clean/rebuild...no dice...shutdown/restart...no
dice...Arghh!! Switched back to a previous install (I20081202-1812)..all OK."