1.
2009-3-25 20:52:49 org.apache.struts.action.RequestProcessor processException
警告: Unhandled Exception thrown: class java.lang.IllegalArgumentException
2009-3-25 20:52:49 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet action threw exception
java.lang.IllegalArgumentException: No SqlMapClient specified
2.
2009-3-25 21:45:37 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet action threw exception
java.lang.NullPointerException
at web.action.system.UsersAction.viewProfile(UsersAction.java:84)
at web.action.system.UsersAction.execute(UsersAction.java:65)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
同事今天遇到这个问题是因为直接实例化(new)了DAO对象,而不是从spring容器中获取的,所以会报这个错,解决办法:
ApplicationContext context =new ClassPathXmlApplicationContex("applicationContext.xml");
usersDAO= (DAOIBtaisTemplateIMPL) context.getBean("usersDAO");
at org.springframework.util.Assert.notNull(Assert.java:112)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:166)
at org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithListResult(SqlMapClientTemplate.java:249)
at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:296)
at com.raycloud.dao.impl.ItemCheckTaskDaoImpl.queryItemCheckTask(ItemCheckTaskDaoImpl.java:66)
at com.raycloud.thread.ItemCheckThread.run(ItemCheckThread.java:57)
at java.lang.Thread.run(Thread.java:619)
在做spring + ibatis整合时,容易报此类异常
原因是在创建DAO对象时使用了 new xxxDaoImpl()的方法,应该用使用
WebApplicationContext beanFactory = WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
ItemCheckTaskDao itemCheckTaskDao = (ItemCheckTaskDao) beanFactory.getBean("itemCheckTaskDao");
我自己是这么写的
ApplicationContext context =new FileSystemXmlApplicationContext("/WebRoot/WEB-INF/applicationContext.xml");
iURLinsertDAO= (IURLinsertDAOImpl) context.getBean("iURLinsertDAO");
因为 ClassPathXmlApplicationContex("applicationContext.xml"); 中必须把xml发到src下 而FileSystemXmlApplicationContext("/WebRoot/WEB-INF/applicationContext.xml");不用