Note: error is comming @ line: 59
This is the source code where i m getting nullpointer exception , I am unable to know where exactly this is not getting value. this code is working at another machine but not on my machine though i compiled it from machine on which its working
plz help i got stuct @work

public void generateReport(String ctype,String cstype,String locid,String orgId,HttpServletRequest request,HttpServletResponse response,String reportname) throws ServletException,IOException,SAXException
	{
         PrintService service = null;
		 InputStream input=null;
		 Connection con=null;
		 ServletContext servletCtx=null;
		System.out.println("jasper report name"+reportname);


		try{
			 con = Connect.getConnection();
		 String path="C:/Program Files/Apache Software Foundation/Tomcat 5.5/webapps/"+request.getContextPath()+"/jReport/";
		 String realPath = request.getRealPath("/jReport/"+reportname+".jasper");
		 System.out.println("generateDeathReport path="+path);
		 System.out.println("generateDeathReport realPath="+realPath);
			
		 String rFile=request.getRealPath("/jreport/"+reportname+".jasper");
		 File RFile= new File(request.getRealPath("/jreport/"+reportname+".jasper"));


		JRPdfExporter pdfExporter = new JRPdfExporter();


			Map rptHash = new HashMap();
			
			FontKey key = new FontKey("ArialUNI", false, false);
			
			
		   /* rptHash.put("typeId", ctype);
		    rptHash.put("sub_typeId", cstype);
		    rptHash.put("orgId", orgId);
			rptHash.put("locid", locid); */

			rptHash.put("typeId", "0");
		    rptHash.put("sub_typeId", "0");
		    rptHash.put("orgId", "2");
			rptHash.put("locid", "0");

			System.out.println("TYPEID==sub_typeId==orgId=="+rptHash);

FileInputStream fs=new FileInputStream(rFile);

JasperReport template=(JasperReport)JRLoader.loadObject(RFile);
System.out.println("Loaded Successfully the jasper file!!");
//JasperPrint report=JasperFillManager.fillReport(template,rptHash,con);
System.out.println("Report filled with data");
FileInputStream reportSource=new FileInputStream(rFile);
System.out.println("file found"+reportSource);

try
                {
					
					System.out.println("CON==="+con);
					System.out.println("rptHash==="+rptHash);
					System.out.println("reportSource==="+reportSource);
================================================================================
//this is line where i m getting null pointer exception
===============================================================================                    
JasperPrint oJasperPrint = JasperFillManager.fillReport(reportSource,rptHash, con);
					System.out.println("oJasperPrint");
				    
                    response.setContentType("application/pdf");
					
					pdfExporter.setParameter(JRPdfExporterParameter.CHARACTER_ENCODING, "UTF-8");
					
                    JasperExportManager.exportReportToPdfStream(oJasperPrint,(OutputStream)response.getOutputStream());
				    System.out.println("2. Pdf report generated..");
                    response.setContentType("application/pdf");
				    pdfExporter.exportReport();
                    System.out.println("REPORT GENERATED");
     
                  response.getOutputStream().flush();
                   
                    
                } catch(JRException ex) {                 
                 ex.printStackTrace();
                } catch (IOException ex) {                    
                 ex.printStackTrace();
                }


}catch(JRException jex)
{System.out.println("Jasper Exception :"+jex.getMessage());

System.out.println("Jasper Exception :"+jex.getStackTrace());
System.out.println("Jasper Exception :"+jex.getLocalizedMessage());

}
			catch(Exception e)
			{
				System.out.println("EXCEPTION IN jaspaer1 CLASS-generateReport()-e="+e);
		
				StringWriter stringWriter = new StringWriter();
				PrintWriter printWriter = new PrintWriter(stringWriter);
				e.printStackTrace(printWriter);
				response.setContentType("text/plain");
				//response.getOutputStream().print(stringWriter.toString());
			}

	}

What this means is that your JasperFillManager is null, or perhaps something in the method fillReport. Try to put some printlns on different spots, or just use the debugging tool to check what your variables are, and go back like that.

i also tried n put the hardcoded values at parameters and also displayed parameters value at console values are correct but still it is showing NullPointerException. all three values souce file,parameters and connection object are properly provided to the method.. The sql query i wrote in jasper report is working properly when i execute it in sql developer. plz rply asap

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.