pavelgoev Posted May 27, 2010 Share Posted May 27, 2010 Hello, I am getting Null Pointer Exception when fill the report (generate a PDF); please see the code and stack trace below.The report works in iReport (use the same db connection), and dosn't work when use JasperReports.Use the latest version 3.7.2, Java 5Would appreciate if any ideas what's wrong.Error:10/05/27 15:10:04 java.lang.NullPointerException10/05/27 15:10:04 at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:63)10/05/27 15:10:04 at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402)10/05/27 15:10:04 at com.collectamerica.libra.jasperpdf.JasperPDFGeneration.generatePDFFromDB(JasperPDFGeneration.java:196)10/05/27 15:10:04 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)10/05/27 15:10:04 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)10/05/27 15:10:04 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)10/05/27 15:10:04 at java.lang.reflect.Method.invoke(Method.java:597)10/05/27 15:10:04 at com.evermind.server.ejb.interceptor.joinpoint.EJBJoinPointImpl.invoke(EJBJoinPointImpl.java:35)10/05/27 15:10:04 at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)10/05/27 15:10:04 at com.evermind.server.ejb.interceptor.system.SetContextActionInterceptor.invoke(SetContextActionInterceptor.java:44)10/05/27 15:10:04 at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)10/05/27 15:10:04 at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)10/05/27 15:10:04 at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)10/05/27 15:10:04 at com.evermind.server.ejb.interceptor.system.TxRequiredInterceptor.invoke(TxRequiredInterceptor.java:50)10/05/27 15:10:04 at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)10/05/27 15:10:04 at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)10/05/27 15:10:04 at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)10/05/27 15:10:04 at com.evermind.server.ejb.InvocationContextPool.invoke(InvocationContextPool.java:55)10/05/27 15:10:04 at com.evermind.server.ejb.StatelessSessionEJBObject.OC4J_invokeMethod(StatelessSessionEJBObject.java:87)10/05/27 15:10:04 at JasperPDFGeneration_RemoteProxy_3bkcocn.generatePDFFromDB(Unknown Source)10/05/27 15:10:04 at com.collectamerica.libra.jasperpdf.runtime.JasperPDFGenerationWebServiceSoapHttp_Tie.invoke_generatePDFFromDB(JasperPDFGenerationWebServiceSoapHttp_Tie.java:123)10/05/27 15:10:04 at com.collectamerica.libra.jasperpdf.runtime.JasperPDFGenerationWebServiceSoapHttp_Tie.processingHook(JasperPDFGenerationWebServiceSoapHttp_Tie.java:330)10/05/27 15:10:04 at oracle.j2ee.ws.server.StreamingHandler.handle(StreamingHandler.java:297)10/05/27 15:10:04 at oracle.j2ee.ws.server.JAXRPCProcessor.doEndpointProcessing(JAXRPCProcessor.java:431)10/05/27 15:10:04 at oracle.j2ee.ws.server.WebServiceProcessor.invokeEndpointImplementation(WebServiceProcessor.java:379)10/05/27 15:10:04 at oracle.j2ee.ws.server.JAXRPCProcessor.doRequestProcessing(JAXRPCProcessor.java:294)10/05/27 15:10:04 at oracle.j2ee.ws.server.WebServiceProcessor.processRequest(WebServiceProcessor.java:114)10/05/27 15:10:04 at oracle.j2ee.ws.server.JAXRPCProcessor.doService(JAXRPCProcessor.java:151)10/05/27 15:10:04 at oracle.j2ee.ws.server.WebServiceServlet.doPost(WebServiceServlet.java:200)10/05/27 15:10:04 at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)10/05/27 15:10:04 at javax.servlet.http.HttpServlet.service(HttpServlet.java:857)10/05/27 15:10:04 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:734)10/05/27 15:10:04 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:391)10/05/27 15:10:04 at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:908)10/05/27 15:10:04 at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:458)10/05/27 15:10:04 at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:313)10/05/27 15:10:04 at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:199)10/05/27 15:10:04 at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)10/05/27 15:10:04 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)10/05/27 15:10:04 at java.lang.Thread.run(Thread.java:619) Code: public String generatePDFFromDB(String debtorId, String templateName) throws JRException { String result = "SUCCESS"; /* JasperReport is the object that holds our compiled jrxml file */ JasperReport jasperReport = null; /* JasperPrint is the object contains report after result filling process */ JasperPrint jasperPrint = null; // jasperParameter is a Hashmap contains the parameters // passed from application to the jrxml layout HashMap jasperParameter = new HashMap(); jasperParameter.put("debtorIdParam", "20008764"); try { // connection is the data source we used to fetch the data from Connection con = establishConnection(); // jrxml compiling process// jasperReport =// JasperCompileManager.compileReport(CONTRACT_JASPER_DIR +// "reporttest1.jasper"); InputStream inStream = this.getClass().getResourceAsStream(CONTRACT_JASPER_DIR + "reporttest1.jasper"); jasperReport = (JasperReport)JRLoader.loadObject(inStream); System.out.println("JASPER REPORT"); if (jasperReport == null) System.out.println("JASPER REPORT is null"); if (con == null) System.out.println("JASPER CONNECTION is null"); // filling report with data from data source jasperPrint = JasperFillManager.fillReport(jasperReport, jasperParameter, con);System.out.println("JASPER PRINT"); System.out.println("JASPERTEST " + jasperPrint.toString()); // exporting process export to PDF JasperExportManager.exportReportToPdfFile(jasperPrint, "/mnt/datafiles/creditreports/" + "cbr_" + debtorId + ".pdf"); con.close(); connection.close(); } catch (ClassNotFoundException enotfound) { enotfound.printStackTrace(System.err); System.out.println("ClassNotFoundException JASPER :" + enotfound.getMessage()); } catch (SQLException esql) { esql.printStackTrace(System.err); System.out.println("SQLException JASPER :" + esql.getMessage()); } catch (Exception e) { e.printStackTrace(System.err); System.out.println("Exception JASPER : " + e.getMessage()); } return result; } Link to comment Share on other sites More sharing options...
thangalin Posted May 31, 2010 Share Posted May 31, 2010 Line 196 of JasperPDFGeneration.java is trying to call a method on a null object. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now