Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java exception breakpoint with condition in Eclipse

Is there any way (including a third-party plug-in) to make a Java exception breakpoint in Eclipse that only breaks if a condition is true?

Current Use Case: I am trying to catch a ClassNotFoundException for a particular class in order to debug a class loading issue. Unfortunately, my breakpoint is trapping literally thousands of irrelevant routine exceptions that occur on Tomcat startup. I want to tell Eclipse to break only if -1 < e.getMessage().indexOf(MY_CLASS_NAME).

Help!?

Update: Several answers have suggested to right-click on the exception in the exception properties and click conditional breakpoint. I've already tried this. Up to at least Eclipse Luna Release 2 (v 4.4.2, build id 20150219-0600), this is not option available for exception breakpoints.

For clarity, here is a picture of my exception breakpoint's properties:

enter image description here

like image 592
0xbe5077ed Avatar asked Aug 30 '25 17:08

0xbe5077ed


2 Answers

There is no option to add a condition for an exception breakpoint similar to normal breakpoints. The closest thing you can do is use the Filtering properties page to add a filter on the breakpoint such as the class and/or the package which throws the exception. Or you can filter on a specific thread while debugging.

See http://help.eclipse.org/juno/topic/org.eclipse.jdt.doc.user/tasks/tasks-create-exception-filter-expression.htm for more info.

like image 59
M A Avatar answered Sep 02 '25 06:09

M A


Right click on your break point! -> Properties -> Conditional break point

like image 30
Kristof Avatar answered Sep 02 '25 06:09

Kristof