日期:2014-05-18  浏览次数:20650 次

hibernate的一个异常求解
service代码:
@Transactional 
public void add(Theme transientTheme) throws ThemeExistingException {
System.out.println(themeDao.findByProperty("themeName", transientTheme.getThemeName()).size());
if(themeDao.findByProperty("themeName", transientTheme.getThemeName()).size() != 0) {
throw new ThemeExistingException("主题名" + transientTheme.getThemeName() + "已存在");
} else {
themeDao.save(transientTheme);
}
}

dao代码:
public void save(Theme transientInstance) {
log.debug("saving Theme instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}


我调用service的时候,dao里的代码已经执行,并且成功添加了数据,但确报了一个空指针异常
java.lang.NullPointerException
at org.apache.struts2.components.template.TemplateEngineManager.getTemplateEngine(TemplateEngineManager.java:102)
at org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:555)
at org.apache.struts2.components.UIBean.end(UIBean.java:519)
at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
at org.apache.jsp.jsp.message.message_jsp._jspx_meth_s_005fdebug_005f0(message_jsp.java:122)
at org.apache.jsp.jsp.message.message_jsp._jspService(message_jsp.java:91)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:88)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:164)
at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:367)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:271)
at com.sc.web.intercptor.TitleIntercptor.intercept(TitleIntercptor.java:27)
at com.opensymphony.xwork2.DefaultA