jeroeng Posted April 12 Share Posted April 12 Hi all,I have the requirement to build a report with several subreports which are all based on .csv files. All reports (main and sub's) are working individually as required, but I can't manage to work the sub reports into the main report.Sources:customer.csv => contains customer name and some more information. name, address, billing infoserver.csv => contains customer name, server IP and more information. fqdn, ip, customer, type, purposeMy master report is based on the customer.csv and reports name of all customers in the file. Below each customer name I want to see all servers we manage for this customer, so customers Name is the linking field.Customer-1server-1 10.10.10.1server-2 10.10.10.2Customer-2server-a 192.168.1.1server-b 192.168.1.2Steps I took creating the subreport in the main report:Field name (= customer name) is in the "Detail 1" band of the main report.Drag the subreport element in the "Detail 2" band of the main reportSelect the correct subreport (Server.jxml) which converts automatically to "Server.jasper"Select no datasourceEdit the parameters to have the field Name from the main report be put in parameter Customer in the subreport ($F{Name}Select the subreport and modify the properties:Data Source Expression set to the location of the server.csv ("C:\Users\jeroen_g\xxxxx\Assets_report\server.csv"Running the master report in preview gives the following error:net.sf.jasperreports.engine.JRException: java.lang.ClassCastException: class java.lang.String cannot be cast to class net.sf.jasperreports.engine.JRDataSource (java.lang.String is in module java.base of loader 'bootstrap'; net.sf.jasperreports.engine.JRDataSource is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @484b5a21) at com.jaspersoft.studio.editor.preview.view.control.ReportController.fillReport(ReportController.java:551) at com.jaspersoft.studio.editor.preview.view.control.ReportController.access$18(ReportController.java:526) at com.jaspersoft.studio.editor.preview.view.control.ReportController$1.run(ReportController.java:444) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)Caused by: java.lang.ClassCastException: class java.lang.String cannot be cast to class net.sf.jasperreports.engine.JRDataSource (java.lang.String is in module java.base of loader 'bootstrap'; net.sf.jasperreports.engine.JRDataSource is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @484b5a21) at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:529) at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:357) at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:383) at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:548) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2600) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:825) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:266) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:110) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:621) at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFill.run(BaseFillHandle.java:135) at java.base/java.lang.Thread.run(Unknown Source)Most likely I'm just missing a small piece here, but have been googling and experimenting for almost a day without success. Hope somebody can direct me in the correct way.Thanks,Jeroen - Link to comment Share on other sites More sharing options...
anish.rai Posted April 24 Share Posted April 24 Thank you for posting to the Jaspersoft Community. Our team of experts has read your question and we are working to get you an answer as quickly as we can. If you have a Jaspersoft Professional Subscription plan, please visit https://support.tibco.com/s/ for direct access to our technical support teams offering guaranteed response times. Link to comment Share on other sites More sharing options...
mbielkiewicz Posted April 25 Share Posted April 25 I believe the issue you are facing is due to this step: Data Source Expression set to the location of the server.csv ("C:\Users\jeroen_g\xxxxx\Assets_report\server.csv"What you need to do is ensure that your subreport is pointing to the correct data adapter (in Studio). You do not need to populate the Data Source Expression field in the main report unless you are passing data "thru" to the subreport. 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