Stack trace will give the line numbers if you compile with debug="on" in the ant javac task command or javac -g <files> if command line compiling.
> -----Original Message----- > From: Alex Kravets [mailto:[EMAIL PROTECTED] > Sent: Wednesday, January 19, 2005 12:47 PM > To: Struts Users Mailing List > Subject: Re: NullPointerException, how to determine cause? > > > I am sure this part works, because if comment out try block > everything > works fine. But If the cause of exception is the code in try > block, how > come catch does not work? > > Pavel Kolesnikov wrote: > > >I guess the only plase where NPE may occure is the line: > > > > String sqlQuery = ((ExecuteQueryForm) form).getSQLQuery(); > > > >Are you sure there's a form definition available for this action? It > >means, is there a "name" attribute defined in an appropriate > <action> > >element in your struts-config.xml? > > > >Pavel > > > >On Wed, 19 Jan 2005 12:34:51 -0500, Alex Kravets > ><[EMAIL PROTECTED]> wrote: > > > > > >>I am trying to connect to a database in Action Class and set return > >>data into a vector. Then vector is set into session and session is > >>read from forwarded page. However, I am getting > NullPointerException. > >>Now I put the part of the code that I think might generate an > >>exception into try block, but no luck same exception. In addition, > >>stack trace does not seem to give the line of perform() where error > >>occurs. > >> > >>SEVERE: Servlet.service() for servlet action threw exception > >>java.lang.NullPointerException > >> at app.ExecuteQueryAction.perform(Unknown Source) > >> at > >>org.apache.struts.action.ActionServlet.processActionPerform( > ActionServlet.java:1787) > >> at > >>org.apache.struts.action.ActionServlet.process(ActionServlet > .java:1586) > >> at > >>org.apache.struts.action.ActionServlet.doPost(ActionServlet. > java:510) > >> at > javax.servlet.http.HttpServlet.service(HttpServlet.java:709) > >> at > javax.servlet.http.HttpServlet.service(HttpServlet.java:802) > >> at > >>org.apache.catalina.core.ApplicationFilterChain.internalDoFi > lter(ApplicationFilterChain.java:237) > >> at > >>org.apache.catalina.core.ApplicationFilterChain.doFilter(App > licationFilterChain.java:157) > >> at > >>org.apache.catalina.core.StandardWrapperValve.invoke(Standar > dWrapperValve.java:214) > >> at > >>org.apache.catalina.core.StandardContextValve.invoke(Standar > dContextValve.java:178) > >> at > >>org.apache.catalina.core.StandardHostValve.invoke(StandardHo > stValve.java:126) > >> at > >>org.apache.catalina.valves.ErrorReportValve.invoke(ErrorRepo > rtValve.java:105) > >> at > >>org.apache.catalina.core.StandardEngineValve.invoke(Standard > EngineValve.java:107) > >> at > >>org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAd > apter.java:148) > >> at > >>org.apache.coyote.http11.Http11Processor.process(Http11Proce > ssor.java:825) > >> at > >>org.apache.coyote.http11.Http11Protocol$Http11ConnectionHand > ler.processConnection(Http11Protocol.java:731) > >> at > >>org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(Poo > lTcpEndpoint.java:526) > >> at > >>org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt( LeaderFollowerWorkerThread.java:80) > >> at > >>org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.ru > n(ThreadPool.java:684) > >> at java.lang.Thread.run(Thread.java:595) > >> > >>and Action Class: > >> > >>package app; > >> > >>import java.io.IOException; > >>import java.util.Vector; > >>import javax.servlet.ServletException; > >>import javax.servlet.http.HttpServletRequest; > >>import javax.servlet.http.HttpSession; > >>import javax.servlet.http.HttpServletResponse; > >>import org.apache.struts.action.Action; > >>import org.apache.struts.action.ActionError; > >>import org.apache.struts.action.ActionErrors; > >>import org.apache.struts.action.ActionForm; > >>import org.apache.struts.action.ActionForward; > >>import org.apache.struts.action.ActionMapping; > >>import org.apache.struts.action.ActionServlet; > >>import com.kwi.DBDriver; > >> > >>public final class ExecuteQueryAction extends Action { > >> > >> public ActionForward perform(ActionMapping mapping, > >> ActionForm form, > >> HttpServletRequest request, > >> HttpServletResponse response) > >> throws IOException, ServletException { > >> > >> // Obtain username and password from web tier > >> String sqlQuery = ((ExecuteQueryForm) form).getSQLQuery(); > >> Vector v = new Vector(); > >> HttpSession session = request.getSession(); > >> try{ > >> v = DBDriver.doSelect("generic2",sqlQuery); > >> v.add("test"); > >> session.setAttribute("output",v); > >> } > >> catch(NullPointerException nle){ > >> v.add("no good"); > >> session.setAttribute("output",v); > >> } > >> session.setAttribute("query",form); > >> > >> // Return success > >> return mapping.findForward("success"); > >> > >> } > >> > >>} // End LogonAction > >> > >>thanks, > >>Alex > >> > >>------------------------------------------------------------ > --------- > >>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > >> > >> > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]