struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pavel Kolesnikov <pavel.kolesni...@gmail.com>
Subject Re: NullPointerException, how to determine cause?
Date Wed, 19 Jan 2005 17:43:23 GMT
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
<akravets@kligerweiss.com> 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.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: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message