damiean 2012-03-13 18:33
浏览 269
已采纳

this.getHibernateTemplate() 空指针

[code="java"]
public Manuscript selectByMaid(int id) throws Exception {
Manuscript manuscript = (Manuscript) this.getHibernateTemplate().get(
Manuscript.class, id);
return manuscript;
}
[/code]

这段代码是运行成功的

[code="java"]
public void exportMan(int maid, String name, OutputStream os) throws Exception{
Manuscript m = (Manuscript) this.getHibernateTemplate().get(
Manuscript.class, maid);
}
[/code]
这两个方法是属于同一class里面的 但是报下列错误

[code="java"]
java.lang.NullPointerException
at com.kinrich.mediaStorage.daoimp.ManuscriptDaoImp.exportMan(ManuscriptDaoImp.java:99)
at com.kinrich.mediaStorage.action.ManuscriptAction.getDownloadFile(ManuscriptAction.java:266)
at org.apache.jsp.templates.downinfo_jsp._jspService(downinfo_jsp.java:93)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.kinrich.mediaStorage.Interceptor.CheckInterceptor.doFilter(CheckInterceptor.java:38)
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.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:722)

[/code]

请问这个问题是出在哪里 我调试的时候显示的是this.getHibernateTemplate()为空 但是同一类里面 为什么会有两个结果呢?

  • 写回答

4条回答 默认 最新

  • suziwen 2012-03-14 09:42
    关注

    把相关的代码当附件传下吧,不然还是没法帮你找出问题

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 cplex运行后参数报错是为什么
  • ¥15 之前不小心删了pycharm的文件,后面重新安装之后软件打不开了
  • ¥15 vue3获取动态宽度,刷新后动态宽度值为0
  • ¥15 升腾威讯云桌面V2.0.0摄像头问题
  • ¥15 关于Python的会计设计
  • ¥15 聚类分析 设计k-均值算法分类器,对一组二维模式向量进行分类。
  • ¥15 stm32c8t6工程,使用hal库
  • ¥15 找能接spark如图片的,可议价
  • ¥15 关于#单片机#的问题,请各位专家解答!
  • ¥15 博通raid 的写入速度很高也很低