java.lang.reflect.InvocationTargetException 异常处理分析

java.lang.reflect.InvocationTargetException 

InvocationTargetException 是一种包装由调用方法或构造方法所抛出异常的受查异常。这个异常并不是Eclipse插件开发特有的,而是标准JDK中的,它定义在 java.lang.reflect包下。在进行Java开发的时候很少会接触到这个异常,不过在进行Eclipse插件开发中则不同,很多API都声明抛出此类异常,因此必须对此异常进行处理。

A→B→C

产生原因:举例说明 下面ABC代表三个类  A调用B,B调用C,其中C中操作数据库,B类做业务逻辑处理,要求在业务逻辑报错的情况下,不报错返回异常信息即可{return message};现在B业务已经抛出异常并且要返回message此时再返回数据是就会跑出AOP里面的一个异常

java.lang.reflect.InvocationTargetException 异常处理分析

异常信息:AOP configuration seems to be invalid: tried calling method [public abstract java.lang.String com.th.supcom.mips.internal.api.atm.IInsuranceAtmService.adminissionToSettle(java.lang.String,java.util.Map,java.util.List)] on target [com.th.supcom.mips.im[email protected]19bbb4b]

AOP配置似乎无效  

就是反射调用SyChiInsuranceAtmServiceImpl时获取失败

 

结局办法:配置 A B类的事务,把事务给去除掉,这样即使A B出现异常也会继续执行,不会影响C的事务处理

<aop:pointcut id="interceptorPointCuts"

expression="execution(* com.th.supcom.mips.impl.service..*.*(..))

and !execution(* com.th.supcom.mips.impl.service.internal.core.AtmServiceImpl.*(..))

and !execution(* com.th.supcom.mips.impl.service.external.AtmOutpSettlementServiceImpl.*(..))/>

<aop:advisor advice-ref="txAdvice" pointcut-ref="interceptorPointCuts" />

</aop:config>