source for servlet-api.jar

L

Larry

My project uses servlet-api.jar. When debugging, I wanted to step
into its classes (such as HttpServlet) but I got "Source code not
available". I found what I thought was the source at
https://sdlc4e.sun.com/ECom/EComAct...eeri/1.4.1&fileDirectoryHrefId_20=&LineItem=0

However, when I did "Attach Source" from the debugger, i found that
the source line numbers did not actually correspond to what's in my
version of servlet-api.jar. I tried adding the relevant source code
directory to my project, but that messed me up somehow... I get a
ClassNotFound error on a class that's in my own project.

Help! How do I step through servlet-api.jar ?
 
D

Daniel Pitts

My project uses servlet-api.jar. When debugging, I wanted to step
into its classes (such as HttpServlet) but I got "Source code not
available". I found what I thought was the source athttps://sdlc4e.sun.com/ECom/EComActionServlet/DownloadPage:~:com.sun....

However, when I did "Attach Source" from the debugger, i found that
the source line numbers did not actually correspond to what's in my
version of servlet-api.jar. I tried adding the relevant source code
directory to my project, but that messed me up somehow... I get a
ClassNotFound error on a class that's in my own project.

Help! How do I step through servlet-api.jar ?

servlet-api is implemented by your J2EE application container, so it
depends on which one you are using. If your using resin, look at
there website, if you're using JBoss, look there, etc...
 
L

Larry

servlet-api is implemented by your J2EE application container, so it
depends on which one you are using. If your using resin, look at
there website, if you're using JBoss, look there, etc...

I'm using WebSphere... is that the container?
 
M

Manish Pandit

I'm using WebSphere... is that the container?- Hide quoted text -

- Show quoted text -

Yes, it would be the container. Also, unless you're running websphere
in-process with the debugger or doing remote debugging, you may not be
able to dive deep into container API.

-cheers,
Manish
 
L

Larry

Yes, it would be the container. Also, unless you're running websphere
in-process with the debugger or doing remote debugging, you may not be
able to dive deep into container API.

-cheers,
Manish

OK, but where do I get the correct source code, and what do I do with
it?
 
M

Manish Pandit

OK, but where do I get the correct source code, and what do I do with
it?- Hide quoted text -

- Show quoted text -

Not sure about Websphere - I doubt its code is available.

If it were Tomcat, you can just download the source and attach the
source path in eclipse.

-cheers,
Manish
 
T

Tzadik.Vanderhoof

If you can't get it, you might be able to synthesize it by decompiling
and recompiling. seehttp://mindprod.com/jgloss/decompiler.html

It would probably take a lot of tweaking though.

Thanks for the idea! I decompiled with jReversePro, but the line
numbers of the decompiled code apparently do not match up with the
line numbers in the .class file, because when I step through in the
debugger, it doesn't make sense.

To solve this, I thought of recompiling the decompiled .java files
back to new .class files, but they won't compile.

How can I solve the line number problem?
 
D

Daniel Pitts

OK, but where do I get the correct source code, and what do I do with
it?

The real question is, are you sure you need to go into it? Perhaps
there is a way for you to debug your program without knowing the
containers source-code.
 
L

Larry

The real question is, are you sure you need to go into it? Perhaps
there is a way for you to debug your program without knowing the
containers source-code.

FYI... what I ended up doing is downloading the Java Decompiler (JAD)
and running

jad -sjava -lnc -nonlb HttpServlet.class

The "lnc" switch puts the line numbers from the original source as
comments in the output source code. However, the debugger doesn't
know anything about these comments (or at least I don't know how to
get it to take advantage of that), so I ended up writing a Perl script
to rewrite the output from JAD to actually put each line on the same
physical line number that it was in the original source (by putting in
the right amount of blank lines), and that worked in the debugger.

(A cleaner method would be to go into the class file and renumber the
source lines, but I don't know enough about the format of the class
file to do that)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top