Attach Source Issue in Eclipse
Asked Answered
D

6

5

In Eclipse (Ganymede) I'm debugging some code that uses Apache Commons HttpClient and would like to step into the HttpClient code. I've downloaded the source code and tried to attach it in the normal fashion (CTRL-click on the method name and use the Attach Source button). I've tried to attach both as external file and external folder with no success. I've attached source before with no issues and can currently step into Hibernate source code successfully.

I've even tried editing the .classpath file directly to add sourcepath manually. Still no luck. Refreshing the project, doing a clean build, closing and re-opening Eclipse do not solve the issue. Frustratingly, Eclipse provides no error message; it just does not attach the source.

Here are the entries in .claspath:

<!-- Hibernate. Works -->
<classpathentry kind="lib" path="/myEAP/EarContent/APP-INF/lib/hibernate.jar" sourcepath="D:/Data/Download/hibernate-3.2.2.ga/hibernate-3.2/src"/>

<!-- Commons HttpClient. Will not attach -->
<classpathentry kind="lib" path="/myEAP/EarContent/APP-INF/lib/commons-httpclient.jar" sourcepath="D:/Data/Download/commons-httpclient-3.1/src/java"/>

I've tried changing the path to D:/Data/Download/commons-httpclient-3.1/src and that does not work either.

The directory structure is:

D
  Data
    Download
      commons-httpclient-3.1
        src
          java
            org
              apache
                commons
                  httpclient
                    AutoCloseInputStream.java
                    ... (and so forth)
Devinna answered 10/10, 2008 at 15:53 Comment(1)
Can you reformat the .classpath entries to be visible (after markup)?Simony
S
6

Try pointing it at a directory containing the top level package directly, "D:/Data/Download/commons-httpclient-3.1/src/java" for you. What worked for me was creating a new src zip file containing the "org" folder and everything beneath it.

Here's my .classpath entry, (which works for me) in case it helps:

<classpathentry kind="lib" path="/blib/java/commons-httpclient-3.1/commons-httpclient-3.1.jar" sourcepath="/blib/java/commons-httpclient-3.1/commons-httpclient-3.1-src.zip"/>
Simony answered 10/10, 2008 at 23:47 Comment(0)
P
4

I've found that sometimes, you point to the directory you'd assume was correct, and then it still states that it can't find the file in the attached source blah blah.

These times, I've realized that the last path element was "src". Just removing this path element (thus indeed pointing one level above the actual path where the "org" or "com" folder is located) magically makes it work.

Somehow, Eclipse seems to imply this "src" path element if present, and if you then have it included in the source path, Eclipse chokes. Or something like that.

Perlite answered 20/7, 2010 at 11:47 Comment(0)
F
3

Try attaching the src.zip instead of the unzipped src?

Faceoff answered 10/10, 2008 at 16:4 Comment(2)
Thanks, I think I might try opening the project in Europa.Devinna
Luckily, the JDK src.zip file was installed automatically with my Java installation. The src.zip typical location on windows 64 system is C:\Program Files\Java\jdk_yourVersion.Hanafee
C
2

Try adding it to the source path of your launch configuration.

Checkroom answered 10/10, 2008 at 16:53 Comment(0)
S
1

Attaching sources is not all that is required to step into a library on the classpath; that library must also be compiled with debug symbols. This usually isn't a problem, since most Java libraries are compiled and distributed in such a fashion, but as you have found, some of them are not.

It is interesting to note that you can actually step into external libraries even without the source attached, you just can't see the line-by-line sources (all of the debug info still works).

You could "fix" this problem by compiling a custom version of Commons HttpClient (not too difficult), or just skip the whole "step into the library" idea. As a general development practice, stepping into third-party libraries will rarely yield useful information. I've done it maybe once or twice in the last ten years, neither time did it actually bring me any closer to solving the dilemma at hand.

Sensitive answered 10/10, 2008 at 22:42 Comment(0)
O
1

I think, problem in space (or localized) simbols in path to source archive. Try to move it to another place with simple path.

Oringas answered 6/4, 2011 at 11:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.