如何在db40 Java应用程序中调试“java.lang.NullPointerException”?

时间:2010-01-21 10:54:04

标签: java nullpointerexception

当我运行使用db40的应用程序时,我收到以下错误。

有什么想法吗?一切都很好,Hashtable <String, db4o.Plant> l = db4o.db.getTheDatabase().getPlants();在netbeans中显示OK(所有方法都写得正确)。

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.
exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /plante.jsp at line 37

    34: 
    35: 
    36: <%
    37: Hashtable <String, db4o.Plant> l = db4o.db.getTheDatabase().getPlants();
    38: int i = 0;
    39: 
    40: Iterator<String> iterator = l.keySet().iterator();


    Stacktrace:
        org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)


org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)

    root cause

java.lang.NullPointerException
    org.apache.jsp.plante_jsp._jspService(plante_jsp.java:89)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.

1 个答案:

答案 0 :(得分:1)

我的第一个猜测是db4o.db.getTheDatabase()返回null。