Struts、Spring项目跳到InvocationTargetException(Throwable target)方法

最近在使用Struts、Spring开发项目的过程中,出现了一个很奇怪的问题,在执行Action类中的方法时,不能返回数据,debug后发现进入方法后会跳到下边的这个类的方法中,然后控制台报NullPointerException错误

/**
* Constructs a InvocationTargetException with a target exception.
*
* @param target the target exception
*/
public InvocationTargetException(Throwable target) {
   super((Throwable)null);  // Disallow initCause
   this.target = target;
}

原因:在spring中没有配置实现类,所以dao没有注入。调用方法的时候会调用invoke()方法,这个时候dao为null,所以会报错

解决办法:

1.把该dao实现类在spring中的SqlMapConfig.xml配置一下,

<sqlMap resource="com/jiaonizuoren/dao/ibatis/sqlmap/video/VideoSource.xml"/>

2.配置后还是没解决,最后发现是在applicationContext.xml 也没有配置bean标签 Dao和IbatisDao,配置完成后就成功解决了

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章