I have a web application where I need to find all classes that accesses the http request object (because one of them is causing a hard to find bug). Therefore I would like to put breakpoint in some of the methods of ServletRequest implementation. This implementation is however provided by Weblogic for which I don't have sources. How can I put a breakpoint in a class anywhere in a particular method without having it's source . The Eclipse IDE is preferred.
Asked
Active
Viewed 5,522 times
3 Answers
20
You can set a method breakpoint using the outline view of the class in question. Then the debugger breaks at the first line of the method.

Thorbjørn Ravn Andersen
- 73,784
- 33
- 194
- 347
-
1For some reason the right-click menu for the method does not contain "Toggle Method Breakpoint" on a fresh workspace, but shows up after another breakpoint was set. – Thorbjørn Ravn Andersen May 06 '13 at 11:53
-
Thank you so much for this one. I had been blindly stepping into each method call starting from the code that I actually had the source for, and now it works in a flash – nikodaemus Aug 09 '21 at 15:10
1
Depending on your luck, you can do this with a decompiler. You'll have to place the breakpoint in the appropriate line (which, alas, might not contain "breakpointable" code)
The better way to do this is to create a ServletResponse
wrapper. Incidentally, yesterday I created such a thing (with a slightly different purpose), so here it is:
public class DebugFilter implements Filter {
public void init(FilterConfig filterConfig) {}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
chain.doFilter(request,
new ResponseWrapper((HttpServletResponse) response));
}
public void destroy() {}
}
class ResponseWrapper extends HttpServletResponseWrapper {
public ResponseWrapper(HttpServletResponse response) {
super(response);
}
@Override
public PrintWriter getWriter() throws IOException {
return super.getWriter(); // breakpoint here
}
// Override whichever methods you like
}

Bozho
- 588,226
- 146
- 1,060
- 1,140
-
The problem with the wrapper approach is that I already have wrapper in my application but some framework somehow operates directly on the original request - that's the bug:-). – calavera.info Aug 12 '10 at 09:06
0
I'm afraid you will need the source code if you want this to work.
For debugging, you need readable code + line numbers that match this code. None of these items are included in the class files

KristofMols
- 3,487
- 2
- 38
- 48