?
Solved

setting breakpoints  in eclipse .. any shortcut ?

Posted on 2009-04-28
29
Medium Priority
?
1,439 Views
Last Modified: 2013-12-29
I have a very big existing web application .
In the  DataAccess.java code i have more than 200 methods .
i want to put breakpoints in the start of  all these methods .

I am using eclipse debugger .

is there any shortcut so that i can put breakpoints in start of all these methods ?

i don't want to click 200 times for breakpoints   :)

can you suggest any shortcut ?
0
Comment
Question by:cofactor
  • 15
  • 14
29 Comments
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 24249055
I doubt there is a solution for this problem. The only way I could think of woud be to define an AspectJ Pointcut and assign this to all methods in your DAO ... put the breakpoint in there and you're finished ... If yor're not using AspectJ or any similar thing, this is sort of overkill though ;-)
0
 

Author Comment

by:cofactor
ID: 24249142
>>>yor're not using AspectJ or any similar thing, this is sort of overkill though

that will be much more time consuming  than clicking 200 times in the start of each method for "set breakpoint" :)

i am doing this because i want to know which method in DataAccess.java code  is going to be called when a  jsp submit  operation is done.

Unfortunately , code is so highly complex and bulky  that i  am not interested to go through the code flow  and arrive at the method in the DAO .

Rather i will prefer to use some tricks to find out which method is called when that particular screen operation is done .

i feel , the breakpoint  thingie will work out but again setting 200 breakpoints in the start of every method is discouraging my stamina ........so , can you tell some tricks here ?

open discussion .




0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 24249170
I'd have a look at the JSP, the configuration of the framework and the application code instead of doing that.

But if you are using one common framework in your DAO, how about setting a breakpoint on a little higher level? If you attach a breakpoint to, lets say hibernate Sessions update method, then you should stop wherever update is called. All you have to do now, is go up one level in the Eclipse Debuggers stack trace.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:cofactor
ID: 24249299
>>>But if you are using one common framework in your DAO, how about setting a breakpoint on a little higher level

No common framework.  DAO class has hibernate as well as simple JDBC ...its a mix .
I have told already  that class contains  200 methods.  in some methods hibernate save/saveOrupdate  is happening and in some methods simple JDBC isert/update/select is happening.


>>>If you attach a breakpoint to, lets say hibernate Sessions update method, then you should stop wherever update is called.

>>If you attach a breakpoint to .....

thats exactly my point here :)  how do i set/unset  breakpoints to 200 methods EASILY ?

if i can put these breakpoints at the start of these methods ...my burden will be relieved a lot.

looking for a approach.

open discussion
0
 

Author Comment

by:cofactor
ID: 24249321
in fact , i would have been happier if there were a menu in eclipse debugger "set breakpoints to All methods at start  "  .....just one click  ....and i am done .....relaxed .

i don't see this kind of things here
0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 24249323
Well how about setting a breakpoint in the JDBC executeQuery, executeUpdate method AND the hibernate insert, update, delete methods? Not the DAO methods, the methods of JDBC and Hibernate. I guess there will be about 5-6 Places where you have to add breakpoints. As soon as Eclipse stops, go up one step in your Eclipse-Debugger-Stacktrace.
0
 

Author Comment

by:cofactor
ID: 24249428
>>I guess there will be about 5-6 Places where you have to add breakpoints

No, each of the methods is doing some kind of database operation . i should set in all of these methods.


(i have almost 100+ database tables )
0
 

Author Comment

by:cofactor
ID: 24249444
Hope , you guys understand the problem now.

suggest more choices ......let me check which one could be useful in my case...i'll give that a try.


0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 24249484
Let me repeat this once again:

In your DAOs you will have code ... this code uses eiter JDBC or hibernate ... in order to use JDBC or hibernate you will call things like "connection.prepareStatement()", "stmnt.executeQuery()", ... or for hibernate "session.update()", "session.saveOrUpdate()", "session.save()" or "session.delete()". If you open these methods and set breakpoints there, you will only have to set breakpoints in these (JDBC and Hibernate) classes which are just 5 or 6.
0
 

Author Comment

by:cofactor
ID: 24249670
>>>>>hibernate you will call things like "connection.prepareStatement()", "stmnt.executeQuery()", ... or for hibernate "session.update()", "session.saveOrUpdate()", "session.save()" or "session.delete()". If you open these methods and set breakpoints there

i cant  set breakpoints there .

Here are the efforts i did ...i am sending screen shots  from my eclipse editor  for a better look

step1:  right click on delete()  method of  hibernate in the following code

session.delete(domain)

."open Declaration" . but i cant put breakpoint there .

see the outcome here
http://i218.photobucket.com/albums/cc298/curseofgoldendragon/session.png


step2:
right click on executeQuery()  method of  PreparedStatement in the following code


rs=pstmt.executeQuery();

"open Declaration" . but i cant put breakpoint there .
see the outcome here

http://i218.photobucket.com/albums/cc298/curseofgoldendragon/query.png


Can you comment on these two steps ?


0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 24249701
Ok ... I have the sourcecode for allmost all libraries I use. If you download them for the version of hibernate you are using and extract them anywhere. You can then click on the "Attach Source" Button on those cryptic Class-Views and set the Breakpoints pretty easily. You just have to make sure you got the correct source-version for your jars.
0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 24249712
On your second issue ... the Variable will implement the Interface you are showed, but the implementation class will be a different one. Look for classes implementing this interface and set the breakpoints in there.
0
 

Author Comment

by:cofactor
ID: 24249803
>>>>You just have to make sure you got the correct source-version for your jars.

I am using hibernate 2 ...i'll try to download the source files from the hibernate site's achieve. i'll update you if i dont get it .


>>>the Variable will implement the Interface you are showed, but the implementation class will be a different one. Look for classes implementing this interface and set the breakpoints in there.

yea...i understand this.

I have two questions here.

(a)"Look for classes implementing this interface"   ......i am not sure how to get this  . where  i can avail this ? ...as you have seen  i have methods of  both the prepared statement and statement interfaces ......can you provide me a download link from where i can get the source  stuff.


(b) having the  above  source stuff, how do i integrate that in my eclipse editor ? i have not done this earlier ....can you please tell me the steps here .


thanks for the  help.
 
0
 

Author Comment

by:cofactor
ID: 24249880
one update :

http://www.hibernate.org/    site is under maintenance  :(

i could not find the download link of hibernate 2


do you have the hibernate 2 source  ? can you upload it somewhere ?

thanks
0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 24249911
Hmmm ... ok ... 2 is rather old ... how about giving JAD a try ;-)

http://sourceforge.net/projects/jadclipse/

If you don't have the sourcecode, It decompiles your class and presents you this code instead ;-)
0
 

Author Comment

by:cofactor
ID: 24250062
Ok , i tried the eclipse JAD .

unfortunately it did not work .

here are the steps  after plugin installation ....




step1:  

i did   "open declaration"   on  delete method of

session.delete(domain)


and got  exception

 TOTAL TIME: 47 ms

JAD REPORTED MESSAGES/ERRORS:


    EXIT STATUS:    0


    CAUGHT EXCEPTIONS:
    java.io.IOException: CreateProcess: jad -p -t4 -lradix10 -radix10 Session.class error=2
    at java.lang.Win32Process.create(Native Method)
    at java.lang.Win32Process.<init>(Win32Process.java:66)
    at java.lang.Runtime.execInternal(Native Method)
    at java.lang.Runtime.exec(Runtime.java:566)
    at jadclipse.JadDecompiler.decompile(JadDecompiler.java:161)
    at jadclipse.JadDecompiler.decompileFromArchive(JadDecompiler.java:218)
    at jadclipse.JadclipseSourceMapper.findSource(JadclipseSourceMapper.java:91)
    at jadclipse.JadclipseSourceMapper.findSource(JadclipseSourceMapper.java:71)
    at jadclipse.JadclipseClassFileEditor.doOpenBuffer(JadclipseClassFileEditor.java:109)
    at jadclipse.JadclipseClassFileEditor.init(JadclipseClassFileEditor.java:56)
    at org.eclipse.ui.internal.EditorManager.createSite(EditorManager.java:773)
    at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:572)
    at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:365)
    at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:552)
    at org.eclipse.ui.internal.EditorReference.getEditor(EditorReference.java:214)
    at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2325)
    at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2258)
    at org.eclipse.ui.internal.WorkbenchPage.access$9(WorkbenchPage.java:2250)
    at org.eclipse.ui.internal.WorkbenchPage$9.run(WorkbenchPage.java:2236)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2231)
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2212)
    at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:263)
    at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:140)
    at org.eclipse.jdt.internal.ui.actions.OpenActionUtil.open(OpenActionUtil.java:49)
    at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:169)




step2:
i did   "open declaration"   on  executeQuery(); method of
rs = pstmt.executeQuery();

and got outcome as ...
http://i218.photobucket.com/albums/cc298/curseofgoldendragon/query1.png



suggestion needed.


0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 24250308
Well did you install Jad anywhere?  You have to download Jad and copy it somewhere and then you have to tell Eclipse where it is located in the preferences.
0
 

Author Comment

by:cofactor
ID: 24257905
>>>Well did you install Jad anywhere?  


Ok. i did not do this earlier . i have updated the settings now . i already have the DJ compiler installed in my machine ...and i am using the jad.exe now

i followed the tutorial steps here ...

http://www.devx.com/Java/Article/22657

after that , when i do the

session.delete(domain)  --->right click ---->open declaration

i get this ...

http://i218.photobucket.com/albums/cc298/curseofgoldendragon/query2.png



and when i  do "open declaration"   on  executeQuery(); method of
rs = pstmt.executeQuery();

i get this ...

http://i218.photobucket.com/albums/cc298/curseofgoldendragon/query3.png



clearly , i cant set the breakpoints there :(



comments please.

thanks


0
 

Author Comment

by:cofactor
ID: 24267182
any update  to this ?
0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 24267676
Can you open the TypeHierarchy and "Focus on" "PreparedStatement" and "Session" (Don't know the correct name of the Interface). YOu should then see a list of classes in your classpath implementing that interface. Double click on them and you should see the correct class.
0
 

Author Comment

by:cofactor
ID: 24268596
>>>Can you open the TypeHierarchy and "Focus on" "PreparedStatement" and "Session" (Don't know the correct name of the Interface).

i just did that ...yea...it now  works partly.

However , I  have two questions

Q1:

though this trick works for "PreparedStatement"  but not for "Session"

i see there are many implementation class for  "PreparedStatement"

http://i218.photobucket.com/albums/cc298/curseofgoldendragon/pstmt.png

can  i use any of the classes  ?  yea, it can decompile the class peacefully ...but which implemented class to pick from this list  ? is there any preference/choice  ?



Q2:


for  hibernate  "Session"  i dont get to see any implemented class    :(

see the screenshot


http://i218.photobucket.com/albums/cc298/curseofgoldendragon/session-1.png



what to do with this ?


thanks for the response.
0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 24270426
To Q1: Take the java.sql version,since this is the one you are defninitely using (You can check in the Import statemnts of your program ... there schould be an:
import java.sql.PreparedStatement;
there somewhere.
0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 24270444
With Q2 you have to check in your sourcecode too, which one you are using. Focus on that interface and let Eclipse show you which classes on your classpath implement this interface.
0
 

Author Comment

by:cofactor
ID: 24276873
>>>>To Q1: Take the java.sql version,since this is the one you are defninitely using (You can check in the Import statemnts of your program ... there schould be an:
import java.sql.PreparedStatement



Yes. i am using java.sql.PreparedStatement.

when i focus on that interface and right click "open Type Hierarchy"  i get this screen

http://i218.photobucket.com/albums/cc298/curseofgoldendragon/impl.png

i see those implemented classes ...but none are from Sun ...they are from
weblogic.jdbc.oci , weblogic.jdbc.oci.xa , weblogic.jdbc.mssqlserver4



>>>>With Q2 you have to check in your sourcecode too, which one you are using. Focus on that interface and let Eclipse show you which classes on your classpath implement this interface.

when i focus on that interface and right click "open Type Hierarchy"  i get this screen

http://i218.photobucket.com/albums/cc298/curseofgoldendragon/sessionimpl.png

this implemented class is from  net.sf.hibernate.jca;

i tried to put breakpoints in methods  but  code is not stopping on those.



comments please.

thanks




0
 

Author Comment

by:cofactor
ID: 24292704
any updates ?
0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 24293302
You do see the [+] In front of allmost all of these Clases? I'd suggest that one of the two PreparedStatement classes contains the implementation you are looking for. But if you are using Oracle, for example, your Implementation might be contained under the OraclePreparedStatement tree. What DB are you using?
0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 24295369
Hi,

by accident, I found a solution for your original question ;-)
I am using Eclispe 3.4.1

Open the Outline-View for your class ... select all methods ... right-click ... select "Toggle Method Breakpoint"

Well ... you never stop learning with Eclipse ;-)
Thanks for having me look deper into this ... will certainly come in handy sometime ;-)
0
 

Author Comment

by:cofactor
ID: 24323527
sorry for delayed response because i was doing some R&D with eclipse 3.4.1 for your last comments .....

btw, here are the updates

>>>What DB are you using?

Oracle 10G


>>>I'd suggest that one of the two PreparedStatement classes contains the implementation you are looking for

umm...ok . but is not there sun implementation in the jdk package ? as i am putting import java.sql.*  in my code ...there should be some sun implementation ....i dont see anything such though :(

well, i have to see for the third party implementation then .  

>>>But if you are using Oracle, for example, your Implementation might be contained under the OraclePreparedStatement tree

I'll check it out and update soon.



>>>>>Open the Outline-View for your class ... select all methods ... right-click ... select "Toggle Method Breakpoint"

I can make this .  but this is not working the way i  was looking for.

see , i have a save button in the screen .....when i click the save  button this calls one of the methods in the DAO class .......there are more than 200 methods in the DAO class ......but this does not show me that specific method now ......it stops in many unwanted places after i Toggle breakpoints in all methods......i am not happy at all.  


So,I am going to give a try to your  earlier trciks i.e breakpoint in the implementation class.

0
 
LVL 20

Accepted Solution

by:
ChristoferDutz earned 800 total points
ID: 24325044
Hey ... you were looking for a way to set a breakpoint in all of your methods at once ;-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month16 days, 20 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question