java.lang.NullPointerException - Cannot Understand Why.

The code below compiles but I keep getting a "java.lang.NullPointerException" error on line 72 at runtime.

Can someone tell me why?  This code calls a .jcx (control) file to query a database and return a RowSet.
package Main.pdfGen;
 
import Main.cntrls.*;
import com.bea.wlw.netui.pageflow.Forward;
import com.bea.wlw.netui.pageflow.PageFlowController;
import java.io.*;
 
//iText imports
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
 
import javax.sql.RowSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import javax.naming.NamingException;
             
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
 
/**
 * @jpf:controller
 * @jpf:view-properties view-properties::
 * <!-- This data is auto-generated. Hand-editing this section is not recommended. -->
 * <view-properties>
 * <pageflow-object id="pageflow:/Main/pdfGen/PdfGenController.jpf"/>
 * <pageflow-object id="action:begin.do">
 *   <property value="80" name="x"/>
 *   <property value="100" name="y"/>
 * </pageflow-object>
 * </view-properties>
 * ::
 */
public class PdfGenController extends PageFlowController
{
    public search searchCNTRL;
    public RowSet pdfRowSet;
 
    /**
     * This method represents the point of entry into the pageflow
     * @jpf:action
     */
    protected Forward begin()throws IOException,SQLException,NamingException
    {   
        HttpServletResponse res;
        HttpServletRequest req;
        ServletOutputStream out;
        res = this.getResponse();
        req = this.getRequest();
        
        res.setContentType("text/HTML");
        out = res.getOutputStream();
        
        String report = req.getParameter("report");
        String dir = req.getParameter("dir");
        String field = req.getParameter("field");
        String value = req.getParameter("value");
        String cnt = req.getParameter("cnt");                                
        
        /*out.print("<html><head></head><body>");
        out.print("Report: " + report + "<br/>");
        out.print("Dir: " + dir + "<br/>");
        out.print("Field: " + field + "<br/>");
        out.print("Value: " + value + "<br/>");
        out.print("Cnt: " + cnt + "<br/>");                                
        out.print("<html><head></head><body>");*/
        
        if(report.equalsIgnoreCase("report_1")){
            // Get DB rows
            pdfRowSet = searchCNTRL.getReportRows(value,"lower(column)","ORDER BY column ASC",0,Integer.parseInt(cnt));  
        }
        
        out.flush();
        out.close();
                
        return null;
    }
}

Open in new window

ericr29Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ksivananthCommented:
searchCNTRL is not initialized!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jonez176Commented:
I'm not familiar with the "search" class, but it probably needs to be initialized, which I don't see happening.  searchCNTRL is probably a NULL object at line 72 and thus the error occurring.  You probably need something along the lines of:

searchCNTRL = new search();

..before you use any methods of searchCNTRL.  Hope this works.
0
ericr29Author Commented:
So the code above would be changed to look like this:
public class PdfGenController extends PageFlowController
{
    public search searchCNTRL;
    searchCNTRL = new search();
    public RowSet pdfRowSet;
 
...

Open in new window

0
Jonez176Commented:
Yes.  You may need to specify some parameters though.  If your IDE doesn't give you the list of constructors, consult your documentation on the "search" class.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java App Servers

From novice to tech pro — start learning today.