The two lines I think you want to validate first are: String sqlQuery = ((ExecuteQueryForm) form).getSQLQuery();
and session.setAttribute("query",form); Since they are not within your catch, they could cause problems. If your form is null, as someone else said, you'd be in trouble. Also, if for some reason session is null, same deal. This possibility is what I'd suspect first frankly... Note that you are adding to session in your catch... if session is null at that point, then it obviously was null before, which probably caused the original exception... in that cause you'd be throwing another exception from INSIDE the catch block, and that will not be caught until later in the chain, not handled by your code as posted here anyway. I'd have to verify myself, but I could see where that might cause the stack trace to not have a location. That's all that sticks out to me after a cursory glance. -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com On Wed, January 19, 2005 12:34 pm, Alex Kravets said: > 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.internalDoFilter(ApplicationFilterChain.java:237) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) > at > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214) > at > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) > at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) > at > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) > at > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) > at > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) > at > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825) > at > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731) > at > org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526) > at > org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) > at > org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(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]