Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么行号通常不打印在proxys的异常日志中?_Java_Spring_Exception_Proxy - Fatal编程技术网

Java 为什么行号通常不打印在proxys的异常日志中?

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.

为什么spring Proxy不打印行号

有时我在日志中看到行号没有打印出来。我主要看到了spring CGLIB代理。例如 在下面的堆栈跟踪中,我看到没有为spring管理的CustomerServiceBean代理打印行号

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行号?