使用Eclipse和Java EE代码进行调试 session 很痛苦,我希望有人能提供比我更好的方法。

这是2个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

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

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

我知道Eclipse中的步骤过滤器,并尝试使用它们,但是一些自动生成的代理类被注入(inject)到我自己的包中,因此我不容易使用它。

有人对此有好的解决方案吗?

更新

使用以下步骤过滤器暂时跳过所有不需要的步骤:
*$$*  // for CGLib proxies
*$LocalBeanProxy  // for other EJB proxies
java.*
net.sf.*
sun.*

编辑2

这是MyService类的示例:
public void removeScheduledEvent(ScheduledEvent event) {
    // ...
    otherEJB.doStuff(event);
}

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

最佳答案

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

Eclipse debugging / step into method skipping AOP wiring

How to filter dynamically generated classes in debug view?

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

*$LocalBeanProxy
*$CGLibInterceptor
net.sf.*
org.apache.geronimo.*
org.apache.naming.*
org.apache.openejb.*
org.apache.tomee.*
org.apache.webbeans.*

关于java - 进入Eclipse中的Java EE代码,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13090495/

10-11 02:42
查看更多