Java 为什么行号通常不打印在proxys的异常日志中?
为什么spring Proxy不打印行号 有时我在日志中看到行号没有打印出来。我主要看到了spring CGLIB代理。例如 在下面的堆栈跟踪中,我看到没有为spring管理的CustomerServiceBean代理打印行号Java 为什么行号通常不打印在proxys的异常日志中?,java,spring,exception,proxy,Java,Spring,Exception,Proxy,为什么spring Proxy不打印行号 有时我在日志中看到行号没有打印出来。我主要看到了spring CGLIB代理。例如 在下面的堆栈跟踪中,我看到没有为spring管理的CustomerServiceBean代理打印行号 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
at com.xeb.customer.account.CustomerServiceBean$$EnhancerByCGLIB$$5a0112c7.getCustomerDetails(<generated>)
at com.xeb.customer.account.CustomerUtil.getCustomerDetails(CustomerUtil.java:142)
org.springframework.aop.framework.ReflectiveMethodInvocation.procedure(ReflectiveMethodInvocation.java:172)上的
位于org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
在com.xeb.customer.account.CustomerServiceBean$$EnhancerByGlib$$5a0112c7.getCustomerDetails()上
在com.xeb.customer.account.CustomerUtil.getCustomerDetails(CustomerUtil.java:142)上
知道为什么吗?是否也有在代理中打印行号的配置
更新:-我知道代理是在运行时生成的,所以打印它们的行是没有意义的(如果打印不重要)。但我的问题是
如何获取
CustomerServiceBean.java
中的异常行,这是代理CustomerServiceBean$$EnhancerByGlib$$5a0112c7后面的实际类。getCustomerDetails
?这些代理类在运行时通过直接字节码生成动态生成。因此,这些类没有相应的java源文件
虽然分配(随机)行号在技术上是可行的,但这并没有什么意义
如果在类的代码中引发异常,堆栈跟踪将包含类的名称和相应的行号 作为一个(假设的)示例,根据您提供的堆栈跟踪:
at com.xeb.customer.account.CustomerServiceBean.getCustomerDetails(CustomerServiceBean.java:<your linenumber>)
at ...
at java.lang.reflect.Method.invoke(Method.java:...)
at ...
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
at com.xeb.customer.account.CustomerServiceBean$$EnhancerByCGLIB$$5a0112c7.getCustomerDetails(<generated>)
at com.xeb.customer.account.CustomerUtil.getCustomerDetails(CustomerUtil.java:142)
位于com.xeb.customer.account.CustomerServiceBean.getCustomerDetails(CustomerServiceBean.java:)
在
在java.lang.reflect.Method.invoke(Method.java:…)
在
位于org.springframework.aop.framework.ReflectiveMethodInvocation.procedue(ReflectiveMethodInvocation.java:172)
位于org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
在com.xeb.customer.account.CustomerServiceBean$$EnhancerByGlib$$5a0112c7.getCustomerDetails()上
在com.xeb.customer.account.CustomerUtil.getCustomerDetails(CustomerUtil.java:142)上
这些代理类在运行时通过直接字节码生成动态生成。因此,这些类没有相应的java源文件
虽然分配(随机)行号在技术上是可行的,但这并没有什么意义
如果在类的代码中引发异常,堆栈跟踪将包含类的名称和相应的行号 作为一个(假设的)示例,根据您提供的堆栈跟踪:
at com.xeb.customer.account.CustomerServiceBean.getCustomerDetails(CustomerServiceBean.java:<your linenumber>)
at ...
at java.lang.reflect.Method.invoke(Method.java:...)
at ...
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
at com.xeb.customer.account.CustomerServiceBean$$EnhancerByCGLIB$$5a0112c7.getCustomerDetails(<generated>)
at com.xeb.customer.account.CustomerUtil.getCustomerDetails(CustomerUtil.java:142)
位于com.xeb.customer.account.CustomerServiceBean.getCustomerDetails(CustomerServiceBean.java:)
在
在java.lang.reflect.Method.invoke(Method.java:…)
在
位于org.springframework.aop.framework.ReflectiveMethodInvocation.procedue(ReflectiveMethodInvocation.java:172)
位于org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
在com.xeb.customer.account.CustomerServiceBean$$EnhancerByGlib$$5a0112c7.getCustomerDetails()上
在com.xeb.customer.account.CustomerUtil.getCustomerDetails(CustomerUtil.java:142)上
显示完整的堆栈跟踪肯定有助于确定问题的位置。当前堆栈跟踪提取仅显示从CustomerUtil.getCustomerDetails()
到spring代码(经过良好测试)层的调用,而问题最有可能出现在从方法拦截器调用的代码中。显示完整的堆栈跟踪肯定有助于确定问题的位置。当前的堆栈跟踪提取仅显示从CustomerUtil.getCustomerDetails()
到spring代码(经过良好测试)层的调用,而问题最有可能出现在从方法拦截器调用的GET代码中。但代理后面还有一个实际的类。所以在我的例子中,代理实际上会调用CustomerServiceBean,在我实际的类中的某个地方,我得到了一个错误。我怎样才能得到它?@scottmiles代理背后的代码,正如从ReflectiveMethodInvocation.continue
调用的某个地方调用的一样,因此您要查找的行号更接近堆栈跟踪的开头在我的例子中,我刚刚在com.xeb.customer.account.CustomerServiceBean$$enhancerbyglib$$5a0112c7.getCustomerDetails()上看到
在堆栈跟踪中。trace?中没有打印实际的bean CustomerServiceBean行号,但代理后面还有一个实际的类。所以在我的例子中,代理实际上会调用CustomerServiceBean,在我实际的类中的某个地方,我得到了一个错误。我怎样才能得到它?@scottmiles代理背后的代码,正如从ReflectiveMethodInvocation.continue
调用的某个地方调用的一样,因此您要查找的行号更接近堆栈跟踪的开头在我的例子中,我刚刚在com.xeb.customer.account.CustomerServiceBean$$enhancerbyglib$$5a0112c7.getCustomerDetails()上看到
在堆栈跟踪中。跟踪中没有打印实际的bean CustomerServiceBean行号?