在Eclipse中进入Java EE代码

ber*_*nie 7 java eclipse debugging java-ee

Eclipse和Java EE代码中的调试会话很痛苦,我希望有人比我的方法更好.

这是两个EJB无状态bean方法之间的典型调用堆栈(使用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   
Run Code Online (Sandbox Code Playgroud)

这是我不想检查的30行Java EE管道方法调用!

进入方法时跳过所有这一切的唯一可靠方法是在下一个方法调用中放置一个断点,然后点击"Step Over"而不是"Step Into".但是,与简单的"Step Into"相比,一直设置断点是一个很大的麻烦.当我需要走出我正在检查的方法时,我必须重复同样的事情.

我知道Eclipse中的步骤过滤器并尝试使用它们,但是一些自动生成的代理类被注入我自己的包中,所以我不能轻易使用它.

有人有一个很好的解决方案吗?

更新

使用以下步骤过滤器暂时跳过所有不需要的步骤:

*$$*  // for CGLib proxies
*$LocalBeanProxy  // for other EJB proxies
java.*
net.sf.*
sun.*
Run Code Online (Sandbox Code Playgroud)

编辑2

以下是MyService类的示例:

public void removeScheduledEvent(ScheduledEvent event) {
    // ...
    otherEJB.doStuff(event);
}
Run Code Online (Sandbox Code Playgroud)

由于otherEJB是在无状态容器中运行的EJB bean,因此上面的30个调用将通过代理自动插入.

ber*_*nie 4

有关 Eclipse 步骤过滤器的一些信息:

Eclipse 调试/单步执行方法,跳过 AOP 连接

如何在调试视图中过滤动态生成的类?

我在 TomEE 中使用的实际步骤过滤器:

*$LocalBeanProxy
*$CGLibInterceptor
net.sf.*
org.apache.geronimo.*
org.apache.naming.*
org.apache.openejb.*
org.apache.tomee.*
org.apache.webbeans.*
Run Code Online (Sandbox Code Playgroud)