thammond Posted January 20, 2023 Posted January 20, 2023 Hello. I am new to Jasper reports and have a report running three queries that work in the SQL console. I have one parameter that I am mapping to with the queries. Here is an example query with parameter mapping at the bottom. When I try to populate the report with Jaspersoft Studio preview I get the following error: net.sf.jasperreports.engine.JRException: java.lang.ClassCastException: class java.lang.String cannot be cast to class java.util.Map (java.lang.String and java.util.Map are in module java.base of loader 'bootstrap') (see below). I have tried in vain to track down what is causing this. Could some one please help? Thanks in advance.SELECT dfr._record_id, select_project, project_description, to_char(visit_date, 'Day') dayofweek, project_number, client, project_manager, to_char(visit_date, 'mm/dd/yyyy') visit_date, newfields_representative, ((case when pl_photo is null then 0 else pl_photo end)) count_photo, outfalls_free, outfall_obstruction_comment, outfall_obstruction_remedy, outfall_plugs_in_place, outfall_plugs_comment, outfall_plugs_remedy, east_pile_berm_inspection, east_pile_berm_comment, east_pile_berm_remedyFROM public."AltEn Weekly Inspections" dfrleft join (Select _parent_id, count(take_photo) pl_photo from public."AltEn Weekly Inspections - photo_log" group by _parent_id) pl on pl._parent_id = dfr._record_idwhere dfr. _record_id = $P{EventID};Full error log:net.sf.jasperreports.engine.JRException: java.lang.ClassCastException: class java.lang.String cannot be cast to class java.util.Map (java.lang.String and java.util.Map are in module java.base of loader 'bootstrap') at com.jaspersoft.studio.editor.preview.view.control.ReportController.fillReport(ReportController.java:553) at com.jaspersoft.studio.editor.preview.view.control.ReportController.access$18(ReportController.java:528) at com.jaspersoft.studio.editor.preview.view.control.ReportController$1.run(ReportController.java:446) 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 java.util.Map (java.lang.String and java.util.Map are in module java.base of loader 'bootstrap') at net.sf.jasperreports.engine.fill.JRFillSubreport.getParameterValues(JRFillSubreport.java:716) at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateParameterValues(JRFillSubreport.java:559) at net.sf.jasperreports.components.table.fill.FillTableSubreport.evaluateParameterValues(FillTableSubreport.java:118) at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:534) at net.sf.jasperreports.components.table.fill.FillTableSubreport.evaluateSubreport(FillTableSubreport.java:112) at net.sf.jasperreports.components.table.fill.FillTable.evaluate(FillTable.java:136) at net.sf.jasperreports.engine.fill.JRFillComponentElement.evaluate(JRFillComponentElement.java:110) 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:2613) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:836) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:275) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFill.run(BaseFillHandle.java:135) at java.base/java.lang.Thread.run(Unknown Source)
Solution lucianc Posted January 20, 2023 Solution Posted January 20, 2023 It looks like you have a parametersMapExpression in your report (under the dataset of a table) that evaluates to a String object instead of a java.util.Map.You can check it in Jaspersoft Studio by selecting the table and then looking in the Properties view, Dataset tab, at Parameters Map. That expression needs to evaluate to a java.util.Map instance.Regards,Lucian 1
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