Bug 17209 - Eclipse says "Import cannot be resolved" for several external JARs
Summary: Eclipse says "Import cannot be resolved" for several external JARs
Status: RESOLVED DUPLICATE of bug 10207
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 F2   Edit
Assignee: DJ Houghton CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-05-23 08:44 EDT by Damien Lecan CLA
Modified: 2002-05-31 12:02 EDT (History)
1 user (show)

See Also:


Attachments
Log4j jar file (218.23 KB, application/octet-stream)
2002-05-27 03:17 EDT, Damien Lecan CLA
no flags Details
Custom jar file (image management) (84.17 KB, application/octet-stream)
2002-05-27 03:17 EDT, Damien Lecan CLA
no flags Details
Comparison between different situations (65.77 KB, image/jpeg)
2002-05-28 04:16 EDT, Damien Lecan CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Damien Lecan CLA 2002-05-23 08:44:19 EDT
Using Eclipse F1 (same problem with M5), I have a problem with an external jar.

I add an external jar to my project in the properties of it.
No problem appears when the project is compiled.

But, Eclipse always underlines objects, types, imports, ... that concern
this external jar. For example, for an import, it writes 'import package
cannot be resolved', but there no pb with the java compilator (in eclipse of
course).

This problem doesn't appear for every new project, but it always appears when 
Eclipse is configured to separate source and binary files. This must be done in 
the preferences of Eclipse, not when creating the new project.

The problem appears neither with all jar files nor with "internal" jar files 
(not external jar files)
Comment 1 Erich Gamma CLA 2002-05-25 07:12:34 EDT
suspect that the reconciler reports incorrect problems in this case. Moving to 
JDT Core for investigation.
Comment 2 Philipe Mulet CLA 2002-05-25 08:32:37 EDT
Damien - Could you supply this JAR ? Suspect it contains some entries which are 
fooling us when resolving anything against it.
Comment 3 Damien Lecan CLA 2002-05-27 03:17:24 EDT
Created attachment 1066 [details]
Log4j jar file
Comment 4 Damien Lecan CLA 2002-05-27 03:17:54 EDT
Created attachment 1067 [details]
Custom jar file (image management)
Comment 5 Damien Lecan CLA 2002-05-27 03:18:57 EDT
Sorry for answering so late.

I attached both jar files which Eclipse is in trouble with.
One is provided by the Apache Fundation, Log4J, and available here :
http://jakarta.apache.org/log4j/docs/index.html

The other is a custom jar file which manages a particular kind of images.
Comment 6 Olivier Thomann CLA 2002-05-27 13:32:22 EDT
I cannot reproduce using the custom.jar file. I could import types from that jar (using it as an 
external jar) without any problem. Could you please submit a samble of code that points to the 
problem?
Thanks.
Comment 7 Olivier Thomann CLA 2002-05-27 17:11:08 EDT
It should be read "a sample of code" instead of "a samble of code".
Comment 8 Damien Lecan CLA 2002-05-28 04:16:06 EDT
It is very hard to reproduce the problem in a "clean" project.

When I submitted the problem, there was a procedure that produced sometimes the 
problem. Today, that don't wanna "don't work" ;o)

But for my complete project, it always appears if I use both files jar as 
external files if they are located INTO a subfolder of the project. If they are 
anywhere else, nothing happens. But i can't show this again in a new project.

See the new attachment (17209.jpg)

Can't do more, sorry.
Comment 9 Damien Lecan CLA 2002-05-28 04:16:56 EDT
Created attachment 1082 [details]
Comparison between different situations
Comment 10 Olivier Thomann CLA 2002-05-28 14:49:14 EDT
How did you create your external jars located in the subfolder without having the full path in the 
package view? When I tried, I got:
d:/workspaces/test/P/lib/custom.jar displayed in the 
package view and not lib/custom.jar like in your comparison.
I used the project properties to 
do it. Did you change manually the .classpath of your project?
Comment 11 Damien Lecan CLA 2002-05-29 04:11:25 EDT
> Did you change manually the .classpath of your project?
Never !

I will try to be very precise.

Here is an example of architecture :

c:\
  +-Eclipse\
  |        +...
  |        +workspace\
  |
  +-MyProject\
  |          +...
  |          +lib\
  |              +jarOne.jar
  +-Z\
     +jarTwo.jar


So, there is 2 jar files, one in a subfolder of my project, on outside of my 
project.

In the project properties, if i add jarOne as "add External JARs...", there is 
a problem (1st image). In .classpath, i get :
<classpathentry kind="lib" path="C:/MyProject/lib/jarOne.jar"/>
Eclipse shows just "lib/jarOne.jar" in packages view.

In the project properties, if i ass jarTwo as "add External JARs...", there is 
no problem (2nd image). In .classpath, i get :
<classpathentry kind="lib" path="C:/Z/jarTwo.jar"/>
Eclipse shows "C:\Z\jarOne.jar" in packages view.

In the project properties, if I add jarOne as "add JARs...", there is no 
problem (3rd image). In .classpath, I get :
<classpathentry kind="lib" path="lib/jarOne.jar"/>
Eclipse shows "lib/jarOne.jar" in packages view.

I remind you that I created this project with a previous version of Eclipse, 
and if i try to reproduce the behavior on a new clean workspace, the problem 
doesn't appear.
More, Eclipse always shows the full path for external jars (remember the 1st 
case, only relative path is showed).

I think something is wrong somewhere in a configuration file, but I don't now 
what.
Comment 12 Philipe Mulet CLA 2002-05-29 13:09:34 EDT
David - please investigate if this is a duplicate of bug 18190.
Comment 13 Adrian Cho CLA 2002-05-29 14:13:58 EDT
The log4j.jar which has been attached to this bug report is:

    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.

Any use of the logj4.jar is subject to the terms and conditions of the Apache 
Software License 1.1.  More specifically:

 * 1. Redistributions of  source code must  retain the above copyright  notice,
 *    this list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 
 * 3. The end-user documentation included with the redistribution, if any, must
 *    include  the following  acknowledgment:  "This product includes  software
 *    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
 *    Alternately, this  acknowledgment may  appear in the software itself,  if
 *    and wherever such third-party acknowledgments normally appear.
 * 
 * 4. The names "log4j" and  "Apache Software Foundation"  must not be used to
 *    endorse  or promote  products derived  from this  software without  prior
 *    written permission. For written permission, please contact
 *    apache@apache.org.
 * 
 * 5. Products  derived from this software may not  be called "Apache", nor may
 *    "Apache" appear  in their name,  without prior written permission  of the
 *    Apache Software Foundation.
 * 
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
 * APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
 * DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
 * OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
 * ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
 * (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Comment 14 David Audel CLA 2002-05-30 06:17:41 EDT
this is not a duplicate because there is only one project in this test case.
Comment 15 David Audel CLA 2002-05-30 08:54:29 EDT
I can reproduce this bug with the following installation:
C:\
 +Eclipse\
 |       +...
 |       +workspace\
 +MyProject\
         +src\
         |   +Test.java
         +bin\
         +lib\
             +foo.jar
                  +p1\
                     +X.class

Test.java :
-----------------------------
import p1.*;
public class Test {
}
-----------------------------
X.class :
-----------------------------
package p1;
public class X {
}
-----------------------------

With this workspace add  foo.jar to MyProject as external jar.

.classpath show this jar as external but package view show this jar as internal.
The import statement is underlines but there is no problem with compilation.
Comment 16 David Audel CLA 2002-05-30 09:29:18 EDT
To know if a jar is internal or external, the JavaModel use 
IContainer#findMember(IPath). With the previous test case ,this method should 
return null because the given path is absolute (C:\MyProject\lib\foo.jar). But 
findMember does not return null.

/**
 * @see IContainer#findMember(IPath)
 */
public IResource findMember(IPath path, boolean phantom) {
	path = getFullPath().append(path);
	ResourceInfo info = workspace.getResourceInfo(path, phantom, false);
	return (info == null) ? null : workspace.newResource(path, info.getType
());
}

The problem is that getFullPath().append(path) return '/MyProject/lib/foo.jar' 
with path='C:/MyProject/lib/foo.jar'. This new path is identical to the project 
relative path. That's why the result is not correct.

Move to Platform/Core.




Comment 17 John Arthorne CLA 2002-05-31 12:02:40 EDT

*** This bug has been marked as a duplicate of 10207 ***