How to debug "java.lang.NullPointerException" in a db40 Java app?
Whe开发者_如何学编程n I run an application that uses db40 I get the following error.
Any ideas? Everything looks fine and Hashtable <String, db4o.Plant> l = db4o.db.getTheDatabase().getPlants();
shows OK in netbeans (all the methods were correctly written).
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.
My first guess would be that db4o.db.getTheDatabase() returns null.
精彩评论