Java_Jasper Posted October 16, 2013 Share Posted October 16, 2013 Hello,I have a report that is passed a field, said field comes from main report. I can run this report in the iReport Designer and everything works as expected between main report and subreport. When I try and run the report in my application I get a null pointer, since my subreport only has one field which is passed in from the main report can someone tell me why this would be happening?I was was thinking it might be an order of operations type issue, so I made a $V counter and used a print when expression in order to control the first iteration but no luck. Any help would be highly appricated.Errors: Could not load object from location : net.sf.jasperreports.engine.JasperReport------------------------------------------------------------------------------------------------------------------------------------------------------Update: After scouring the net I found a helpful tidbit in regards to subreports and Java.// Declare stringString jasperFile = " ";// Define StringjasperFile = directory + "subReport name.jrxml ---Notice the use of Jrxml here//Load the report templates JasperReport jasperReport = JRXmlLoader.load(new FileInputStream(new File( jrxmlFile)));JasperReport subReport = JRXmlLoader.load(new FileInputStream(new File( jasperFile )));// Compile the report templatesJasperReport jasperReport = JasperCompileManager.compileReport( jsapeReport --pass this in from the load above);JasperReport subReport = JasperCompileManager.compileReport(surReport -- pass this in from load above);//Then you add your subReport in your parameter Mapparameters.put("SUBREPORT_JASPER_FILE", subReport);------------------------------------------------------------------------------------------------------------------------------------------------------------------Final Update -- In iReport under paramaters set the "SUBREPORT_DIR"In properties window set the "Paramater Class" == java.lang.Object In properties window under "Subreprort Properties"set the Express Class == net.sf.jasperreports.engine.JasperReportsset the Subreport Expression == $P{SUBREPORT_DIR} -- Notice I am not using the .jasper file here!This will allow a sub report to be run when using iReport deigner 4.6.0 & Jdeveloper 11.1.2.4 the end result is you have to load the subreport and compile it before sending it to the fill manager using the .jrxml file as opposed to the .jasper file. As this is where it would die during debuggin, it would just null out in the print manager.Enjoy! BtW if this worked for you please give me Karma points. 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