views:

436

answers:

5

I am using eclipse europa (3.5) on windows vista home premium 64-bit using JDK 1.6.0_18 (32 BIT).

Normally, I am able to put breakpoints just fine; However, for a particular class which is NOT part of the project (this class is inside a .JAR file (.JAR file is part of the project) ), although I have attached a source directory to this .JAR file, I am unable to place a breakpoint in this class.

If I double-click on the breakpoint pane(left border), I notice that a class breakpoint is placed. I was wondering if there was NO debug info; However, found that this particular class was compiled using ant/javac task using debug="true" and debuglevel="lines,vars,source". I even ran jad on this class to confirm that it indeed contained the debug info.

So, why is eclipse preventing me from placing a breakpoint ?

EDIT : Just so everyone understands the context, this is a webapp running under tomcat 6.0. I am remote debugging the application from eclipse after having started tomcat outside. The application is working just fine. I am trying to understand the behavior of the above class which I'm unable to do since eclipse is not letting me set a BP.

P.S : I saw a few threads here talking about BPs not being hit but in my case, I am unable to place the BP!

P.P.S : I tried JDK 1.6.0_16 before trying out 1.6.0_18.

Thanks for any pointers.

+1  A: 

It sounds like Eclipse cannot find the jar file on the classpath, although you did say that the jar file is part of the project. What happens if you run the application normally? Do you get a ClassDefNotFoundException or something similar?

If you check the tabs on the Run/Debug configuration you should be able to see what paths and jar files are on the classpath at runtime. You can also add jar files that are not needed to build the application but are needed to run it.

richj
hi richj, thanks for your note. when i try to lookup the class using CTRL + SHIFT + T(open type), I am able to open that particular class and eclipse shows me the source that I attached to the .JAR. Although I am able to put BPs on classes that are part of the project, I am unable to put BPs on the above class.
anjanb
That implies that the jar file is on the build classpath. The runtime classpath is not necessarily the same as the build classpath, but I admit this is a long shot as you usually need to actively change it to force the two classpaths to be different. If the application runs through the code when not using the debugger then the problem must be something different.
richj
In this case I would be tempted to set up a small test project to try to work out what is going on. It only needs to contain the problem jar file and a small class containing one or more test methods.
richj
hi richj, I also resolved along similar lines :-)the application works just fine -- it's just that I need to understand exactly how this .JAR classes work.thank you.
anjanb
hi richj, I kinda resolved to such a solution.As you mentioned, the application runs just fine with OR without the debugger. I just want to understand how the code works so I need to be able to set BPs on various classes methods/statements.thank you.
anjanb
A: 

Try to take a look at your configuration Java->debug->Step filtering sometime its enabled and you cannot stop inside a filtered package

Claudio
no step filtering enabled.
anjanb
A: 

although I have attached a source directory to this .JAR file, I am unable to place a breakpoint in this class.

You say "a source directory". Are you sure, it's the same version that was used to compile the jar? If you're attaching a different source code version, the line numbers may not match, and your break point won't hit.

Chris Lercher
hi chris, yes, i compiled the jar myself from the sources. So, i know that the source directory and the .JAR are in sync. Otherwise, This .JAR was prepared from multiple projects. It source directory had the following structuresourceDir A org fcitmuk db B org fcitmuk epihandy C org fcitmuk epihandy xform D org fcitmuk epihandyAny clues ?
anjanb
A: 

I m aware of a bug in eclipse where break points dont work with a specific version of jdk 1.6.x For more info look at here

Cshah
thank you. this was a problem in JDK 1.6.0_14 but was fixed in 1.6.0_16 . I am currently using 1.6.0_18 and I have this issue. Something tells me that I have forgotten something but can't place it! :-(
anjanb
A: 

Use a plugin called Jadclipse to decompile the jar in runtime, place the breakpoint at the point where the JAR method is invoked, then press F6 and you should be able to go into your JAR method.

Vaishak Suresh
I have the source for the .JAR so there is no need for doing JAD at run-time
anjanb
Is the JAR compiled from the same source you have attached? This is crucial because otherwise line numbers don't match and it may not work when you attach the code.
Vaishak Suresh
When source and .JAR are not in sync, then eclipse's breakpoints act crazy and I've seen such a thing happening earlier. But this time, I cannot set a BP anywhere in the class, not even a single BP.
anjanb