7

Debugging sessions in Eclipse and Java EE code are a pain and I'm hoping someone has a better method than mine.

Here is a typical call stack between 2 EJB stateless bean methods (using TomEE 1.0) :

NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]  
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39  
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25  
Method.invoke(Object, Object...) line: 597  
ReflectionInvocationContext$BeanInvocation(ReflectionInvocationContext$Invocation).invoke() line: 181   
ReflectionInvocationContext.proceed() line: 163 
StatsInterceptor.record(InvocationContext, Method) line: 176    
StatsInterceptor.invoke(InvocationContext) line: 95 
GeneratedMethodAccessor35.invoke(Object, Object[]) line: not available  
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25  
Method.invoke(Object, Object...) line: 597  
ReflectionInvocationContext$InterceptorInvocation(ReflectionInvocationContext$Invocation).invoke() line: 181    
ReflectionInvocationContext.proceed() line: 163 
CdiInterceptor.invoke(InvocationContext) line: 129  
CdiInterceptor.access$000(CdiInterceptor, InvocationContext) line: 45   
CdiInterceptor$1.call() line: 66    
CdiInterceptor.aroundInvoke(InvocationContext) line: 72 
GeneratedMethodAccessor34.invoke(Object, Object[]) line: not available  
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25  
Method.invoke(Object, Object...) line: 597  
ReflectionInvocationContext$InterceptorInvocation(ReflectionInvocationContext$Invocation).invoke() line: 181    
ReflectionInvocationContext.proceed() line: 163 
InterceptorStack.invoke(Object...) line: 138    
StatelessContainer._invoke(Method, Method, Object[], Instance, ThreadContext, InterfaceType) line: 226  
StatelessContainer.invoke(Object, InterfaceType, Class, Method, Object[], Object) line: 178 
StatelessEjbObjectHandler(EjbObjectProxyHandler).synchronizedBusinessMethod(Class<?>, Method, Object[], Object) line: 260   
StatelessEjbObjectHandler(EjbObjectProxyHandler).businessMethod(Class<?>, Method, Object[], Object) line: 240   
StatelessEjbObjectHandler(EjbObjectProxyHandler)._invoke(Object, Class, Method, Object[]) line: 91  
StatelessEjbObjectHandler(BaseEjbProxyHandler).invoke(Object, Method, Object[]) line: 284   
MyService$LocalBeanProxy.removeScheduledEvent(ScheduledEvent) line: not available   

That's 30 lines of Java EE plumbing method calls that I don't want to inspect!

My only reliable way to skip all this when stepping into a method is to put a breakpoint in the next method call, then hit "Step Over" instead of "Step Into". However, setting breakpoints all the time like that is a major hassle compared to a simple "Step Into". I have to repeat the same thing when I need to step out of the method I'm inspecting.

I know about step filters in Eclipse and tried using those but some automatically-generated proxy classes are injected in my own packages so I can't easily use that.

Does anybody have a good solution for this?

update

Using the following step filters skips all unwanted steps for now :

*$$*  // for CGLib proxies
*$LocalBeanProxy  // for other EJB proxies
java.*
net.sf.*
sun.*

edit 2

Here's an example from the MyService class:

public void removeScheduledEvent(ScheduledEvent event) {
    // ...
    otherEJB.doStuff(event);
}

Since otherEJB is an EJB bean running in a stateless container, the 30 calls above are inserted automatically via proxies.

bernie
  • 9,820
  • 5
  • 62
  • 92

3 Answers3

4

Some info about Eclipse step filters:

Eclipse debugging / step into method skipping AOP wiring

How to filter dynamically generated classes in debug view?

Actual step filters I use with TomEE:

*$LocalBeanProxy
*$CGLibInterceptor
net.sf.*
org.apache.geronimo.*
org.apache.naming.*
org.apache.openejb.*
org.apache.tomee.*
org.apache.webbeans.*
Community
  • 1
  • 1
bernie
  • 9,820
  • 5
  • 62
  • 92
2

When debugging, simply hold CtrlAlt, hover over the method name where you want to stop again, until it turns into a hyperlink, then click the method name. That feature is called Step into Selection.

Bananeweizen
  • 21,797
  • 8
  • 68
  • 88
  • Thanks for sharing that trick; I didn't know about it. However, this does not skip the 30-some intermediate steps between my own 2 methods. – bernie Oct 26 '12 at 18:55
  • If so, step filters are probably your only solution. I've seen such unwanted behaviour only with mocking frameworks like mockito and there adding step filters is enough to step over every "magically" generated method of the mocking framework. Or is that framework of yours using bytecode manipulation? That might make it even harder. – Bananeweizen Oct 26 '12 at 19:27
-1

code+test (by just running, not setting breakpoints) incrementally. exception stacks are often useless in EE.

  • That works sometimes. In more complicated scenarios like mine, I find it much easier to step through code to find why I get an exception. – bernie Oct 26 '12 at 17:39