views:

2255

answers:

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:

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)

+2  A: 

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

JeeBee
Tried that first. Thanks.
Paul Croarkin
How weird! Good luck.
JeeBee
Thanks, I think I might try opening the project in Europa.
Paul Croarkin
+2  A: 

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

Dave Dunkin
+1  A: 

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.

Daniel Spiewak
+4  A: 

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"/>
Dave L.
A: 

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.

stolsvik