nicoxnoise Posted July 21, 2021 Share Posted July 21, 2021 Hello,i'm tryoing to create report from a csv (coma separated) file with this sample content :Name,UsedCapacity,CollectedTimedisk_pool-dp,66700,"Jan 1, 2020 1:00:00 AM"3 columns :Name (string) -> name like abcde-fg_hijklUsedCapacity (Integer) -> number like 12345CollectedTime --> date format MMM d, yyyy h:mm:ss aIt seems that when i run the preview, i get the error below :Unable to get value for CSV field "UsedCapacity" of class java.lang.Integer.The value from the UsedCapacity column is just a simple number formated like this : 123456 (no decimal, no separator)how can it be that i get this error emssage ?net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.JRException: Unable to get value for CSV field "UsedCapacity" of class java.lang.Integer. 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: net.sf.jasperreports.engine.JRException: Unable to get value for CSV field "UsedCapacity" of class java.lang.Integer. at net.sf.jasperreports.engine.data.JRCsvDataSource.getFieldValue(JRCsvDataSource.java:380) at net.sf.jasperreports.engine.fill.JRFillDataset.setOldValues(JRFillDataset.java:1507) at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1408) at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1384) at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1201) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:117) 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)Caused by: org.apache.commons.beanutils.ConversionException: Unparseable number: "UsedCapacity" at org.apache.commons.beanutils.locale.BaseLocaleConverter.convert(BaseLocaleConverter.java:245) at org.apache.commons.beanutils.locale.LocaleConvertUtilsBean.convert(LocaleConvertUtilsBean.java:286) at net.sf.jasperreports.engine.data.JRAbstractTextDataSource.convertStringValue(JRAbstractTextDataSource.java:78) at net.sf.jasperreports.engine.data.JRCsvDataSource.getFieldValue(JRCsvDataSource.java:356) ... 8 moreCaused by: java.text.ParseException: Unparseable number: "UsedCapacity" at java.base/java.text.NumberFormat.parse(Unknown Source) at org.apache.commons.beanutils.locale.converters.DecimalLocaleConverter.parse(DecimalLocaleConverter.java:253) at org.apache.commons.beanutils.locale.converters.IntegerLocaleConverter.parse(IntegerLocaleConverter.java:219) at org.apache.commons.beanutils.locale.BaseLocaleConverter.convert(BaseLocaleConverter.java:236) ... 11 more Thanks in advance for your help Link to comment Share on other sites More sharing options...
yama818 Posted July 22, 2021 Share Posted July 22, 2021 Check if the checkbox to skip the first line is checked in the data adapter settings of the csv file.If it is not checked, check it.However, even if you overcome this error, an error will occur at the next "CollectedTime".Net.sf.jasperreports.engine.JRException: Unable to get value for CSV field "CollectedTime" of class java.sql.The problem seems to be caused by the classType of "CollectedTime" being 'java.sql.Time'.I tried to solve the problem as follows, but I'm not sure if it's the right way.1. Change the classType of "CollectedTime" in the data source to 'java.lang.String'.2. Create a new variable with a classType of 'java.lang.String'java.util.Date'.3. Write "new SimpleDateFormat("MMM d, yyyy hh:mm:ss a").parse($F{CollectedTime})" in the expression of the new variable.4. Replace "CollectedTime" with a new variable for the chart X axis.I hope this is helpful. Link to comment Share on other sites More sharing options...
nicoxnoise Posted July 27, 2021 Author Share Posted July 27, 2021 Hello, Big thanks for your answer. I think the problem is more in the csv content/format.i have edited the csv file with notepad++ and now it works perfectly.Perhaps a char in the file or something like this. Link to comment Share on other sites More sharing options...
nicoxnoise Posted July 27, 2021 Author Share Posted July 27, 2021 It's just incredible...I create new CSV file from SQl query. content is like this :Name,UsedCapacityGB,CollectedTimeTEST_AdvDisk,0,"Jan 1, 2021 1:00:00 AM"It's exactly the same content format than the other and it doesn't work with always and always and always the same error mesasge :net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.JRException: Unable to get value for CSV field "UsedCapacityGB" of class java.lang.Integer.With the other file, i've just delete one line and repaste it and after this, it works.There isn't any logic in this, is this a software bug ?this is just totaly illogic, i try to use the csv file that work for the other report, and it doesn't work for this new report with exactly the same configuration...incredible Link to comment Share on other sites More sharing options...
nicoxnoise Posted July 27, 2021 Author Share Posted July 27, 2021 i'm sure there is a problem when creating the report.If i Copy/pase the code from the functional report, it's work......here the functional report jrxml :<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.17.0.final using JasperReports Library version 6.17.0-6d93193241dd8cc42629e188b94f9e0bc5722efd --><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="NBPoolUsage" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="5e33a4f2-e708-4e20-8075-bbd421fe77b8"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="NBPoolUsage.xml"/> <queryString language="csv"> <![CDATA[]]> </queryString> <field name="Name" class="java.lang.String"/> <field name="UsedCapacity" class="java.lang.Integer"/> <field name="CollectedTime" class="java.sql.Time"/> <group name="Name"> <groupExpression><![CDATA[$F{Name}]]></groupExpression> </group> <background> <band splitType="Stretch"/> </background> <title> <band height="50" splitType="Stretch"> <property name="com.jaspersoft.studio.unit.height" value="px"/> </band> </title> <summary> <band height="460" splitType="Stretch"> <timeSeriesChart> <chart evaluationTime="Report"> <reportElement x="-20" y="0" width="842" height="460" uuid="a30b8d2b-e63e-4acb-b744-0381eee187fd"> <property name="net.sf.jasperreports.customizer.0.selectionMode" value="allItems"/> <property name="net.sf.jasperreports.customizer.0.allItems" value="true"/> <property name="net.sf.jasperreports.customizer.0.shapeType" value="rectangle"/> <property name="net.sf.jasperreports.customizer.0.shapeWidth" value="1"/> <property name="net.sf.jasperreports.customizer.0.shapeHeight" value="1"/> <property name="net.sf.jasperreports.customizer.class.0" value="net.sf.jasperreports.customizers.shape.LineDotShapeCustomizer"/> </reportElement> <box bottomPadding="0"> <pen lineWidth="1.0" lineStyle="Solid"/> </box> <chartTitle/> <chartSubtitle/> <chartLegend position="Bottom"> <font fontName="SansSerif" size="8"/> </chartLegend> </chart> <timeSeriesDataset> <dataset resetType="Report"/> <timeSeries> <seriesExpression><![CDATA[$F{Name}]]></seriesExpression> <timePeriodExpression><![CDATA[$F{CollectedTime}]]></timePeriodExpression> <valueExpression><![CDATA[$F{UsedCapacity}]]></valueExpression> <labelExpression><![CDATA[$F{Name}]]></labelExpression> </timeSeries> </timeSeriesDataset> <timeSeriesPlot> <plot/> <timeAxisFormat> <axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/> </timeAxisFormat> <valueAxisFormat> <axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/> </valueAxisFormat> </timeSeriesPlot> </timeSeriesChart> </band> </summary></jasperReport> here the report code that doesn't work :<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.17.0.final using JasperReports Library version 6.17.0-6d93193241dd8cc42629e188b94f9e0bc5722efd --><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="PoolUsage6Months" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="135e9cab-53c5-407d-9ca7-c48a8cbe64c4"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="PoolUsage6Months.xml"/> <queryString language="csv"> <![CDATA[]]> </queryString> <field name="Name" class="java.lang.String"/> <field name="UsedCapacity" class="java.lang.Integer"/> <field name="CollectedTime" class="java.sql.Time"/> <group name="Name"> <groupExpression><![CDATA[$F{Name}]]></groupExpression> </group> <background> <band splitType="Stretch"/> </background> <title> <band height="79" splitType="Stretch"/> </title> <summary> <band height="420" splitType="Stretch"> <property name="com.jaspersoft.studio.unit.height" value="px"/> <timeSeriesChart> <chart evaluationTime="Report"> <reportElement x="-20" y="0" width="842" height="420" uuid="7402a8b3-11ba-43c1-bb1c-92d01e77cbba"/> <chartTitle/> <chartSubtitle/> <chartLegend/> </chart> <timeSeriesDataset> <dataset resetType="Report"/> <timeSeries> <seriesExpression><![CDATA["SERIES 1"]]></seriesExpression> <timePeriodExpression><![CDATA[0]]></timePeriodExpression> <valueExpression><![CDATA[0]]></valueExpression> </timeSeries> <timeSeries> <seriesExpression><![CDATA[$F{Name}]]></seriesExpression> <timePeriodExpression><![CDATA[$F{CollectedTime}]]></timePeriodExpression> <valueExpression><![CDATA[$F{UsedCapacity}]]></valueExpression> <labelExpression><![CDATA[$F{Name}]]></labelExpression> </timeSeries> </timeSeriesDataset> <timeSeriesPlot> <plot/> <timeAxisFormat> <axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/> </timeAxisFormat> <valueAxisFormat> <axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/> </valueAxisFormat> </timeSeriesPlot> </timeSeriesChart> </band> </summary></jasperReport> When the report is generating, there is a bug on this section : <timeSeries> <seriesExpression><![CDATA["SERIES 1"]]></seriesExpression> <timePeriodExpression><![CDATA[0]]></timePeriodExpression> <valueExpression><![CDATA[0]]></valueExpression> </timeSeries> <timeSeries> <seriesExpression><![CDATA[$F{Name}]]></seriesExpression> <timePeriodExpression><![CDATA[$F{CollectedTime}]]></timePeriodExpression> <valueExpression><![CDATA[$F{UsedCapacity}]]></valueExpression> <labelExpression><![CDATA[$F{Name}]]></labelExpression> </timeSeries>In the fucntional report, here the lines : <timeSeries> <seriesExpression><![CDATA[$F{Name}]]></seriesExpression> <timePeriodExpression><![CDATA[$F{CollectedTime}]]></timePeriodExpression> <valueExpression><![CDATA[$F{UsedCapacity}]]></valueExpression> <labelExpression><![CDATA[$F{Name}]]></labelExpression> </timeSeries>It seems that there is a block that is built but don't use (in red above). So i have to use the working report code and i can use all the CSV i want.However, the report have been generated exactly with the same method.... Link to comment Share on other sites More sharing options...
nicoxnoise Posted July 27, 2021 Author Share Posted July 27, 2021 And if i change the adaptater value below with the working adaptater :<property name="com.jaspersoft.studio.data.defaultdataadapter" value="NBPoolUsage.xml"/>by<property name="com.jaspersoft.studio.data.defaultdataadapter" value="PoolUsage6Months.xml"/>It doesn't work anymore withe the error emssage :net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.JRException: Unable to get value for CSV field "UsedCapacity" of class java.lang.Integer. In the NBPoolUsage.xml (the working one), i use exactly the same CSV file than in the PoolUsage6Months.xml adaptater (the nonfunctional one). it's completly incredible Link to comment Share on other sites More sharing options...
nicoxnoise Posted July 27, 2021 Author Share Posted July 27, 2021 The problem is really here :When the report is generating, there is a bug on this section : <timeSeries> <seriesExpression><![CDATA["SERIES 1"]]></seriesExpression> <timePeriodExpression><![CDATA[0]]></timePeriodExpression> <valueExpression><![CDATA[0]]></valueExpression> </timeSeries> <timeSeries> <seriesExpression><![CDATA[$F{Name}]]></seriesExpression> <timePeriodExpression><![CDATA[$F{CollectedTime}]]></timePeriodExpression> <valueExpression><![CDATA[$F{UsedCapacity}]]></valueExpression> <labelExpression><![CDATA[$F{Name}]]></labelExpression> </timeSeries>In the fucntional report, here the lines : <timeSeries> <seriesExpression><![CDATA[$F{Name}]]></seriesExpression> <timePeriodExpression><![CDATA[$F{CollectedTime}]]></timePeriodExpression> <valueExpression><![CDATA[$F{UsedCapacity}]]></valueExpression> <labelExpression><![CDATA[$F{Name}]]></labelExpression> </timeSeries> If i remove the red section above, it's working.... Link to comment Share on other sites More sharing options...
yama818 Posted July 27, 2021 Share Posted July 27, 2021 The extra code seems to be the default value where the Chart component is placed.I've tried all sorts of nasty manipulations, but I couldn't reproduce it in my Studio (7.5.0).Hmmm. It might be a software glitch, but I couldn't tell. Link to comment Share on other sites More sharing options...
nicoxnoise Posted July 28, 2021 Author Share Posted July 28, 2021 My version is TIBCO Jaspersoft Studio 6.17.0 and it has been updated 2021-05-13.I downloaded it from sourceforge :https://sourceforge.net/projects/jasperstudio/files/ 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