title: Why does servlet throw this Servlet.service() Exception?
body: <p>I am using Netbeans. I got the following exception when running a servlet which called a method from a session bean.</p>
  
  <pre><code>ApplicationDispatcher[/TheLibrarySystem-war] PWC1231: Servlet.service() for servlet       ListReservations threw exception
  java.lang.NullPointerException
      at org.apache.jsp.ListReservations_jsp._jspService(ListReservations_jsp.java from   :68)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:109)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:389)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:486)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:380)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
      at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
      at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:873)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:558)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:456)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:382)
      at servlet.TheLibrarySystemServlet.processRequest(TheLibrarySystemServlet.java:86)
      at servlet.TheLibrarySystemServlet.doGet(TheLibrarySystemServlet.java:185)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
      at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:315)
      at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
      at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
      at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1093)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1093)
      at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:291)
      at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:666)
      at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:597)
      at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:872)
      at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
      at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
      at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
      at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:264)
      at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
  PWC1412: WebModule[/TheLibrarySystem-war] ServletContext.log():TheLibrarySystemServlet: Exception in TheLibrarySystemServlet.processRequest()
  </code></pre>
  
  <p>The method in the session bean is definitely working fine and returns the correct values back to the servlet side. </p>
  
  <p>The code crashes at:
  dispatcher.forward(request, response);</p>
  
  <p>Googled around and it seems like its not a code issue, any idea what causes it and how to resolve?</p>