Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attach Source Issue in Eclipse

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)
like image 446
Paul Croarkin Avatar asked Oct 10 '08 15:10

Paul Croarkin


People also ask

How do I detach a source in eclipse?

Open the . classpath file and delete the source attachment part. Or in the Build Path control panel, find the jar file and remove the source attachment (it is one of the detailed options there). m2e automatically adds the attached source even after you remove it.


1 Answers

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"/>
like image 96
Dave L. Avatar answered Oct 15 '22 04:10

Dave L.