Hi,
I have been using jasper (iReport) to create a report. When I run the report through Ireport with the already created csv input source from talend the report works correctly and in the preview tab I can see the entire report with no errors. The problem occurs when I try to create the report through the jasper component in a talend job. It throws casting errors almost the same as this (cant post real log as its confidential information):
net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. Cannot cast from Date to String
value = (java.lang.String)(((java.util.Date)field_datum.getValue())); //$JR_EXPR_ID=10$
<---------------------------------------------------------->
2. Cannot cast from Float to String
value = (java.lang.String)(((java.lang.Float)field_netto.getValue())); //$JR_EXPR_ID=11$
<----------------------------------------------------------->
3. Cannot cast from Float to String
value = (java.lang.String)(((java.lang.Float)field_mwst.getValue())); //$JR_EXPR_ID=12$
<---------------------------------------------------------->
4. Cannot cast from Integer to String
value = (java.lang.String)(((java.lang.Integer)field_rabatt.getValue())); //$JR_EXPR_ID=13$
<-------------------------------------------------------------->
5. Cannot cast from Integer to String
value = (java.lang.String)(((java.lang.Integer)field_zbid.getValue())); //$JR_EXPR_ID=14$
<------------------------------------------------------------>
6. Cannot cast from Integer to String
value = (java.lang.String)(((java.lang.Integer)field_ausgewaehlt.getValue())); //$JR_EXPR_ID=16$
<------------------------------------------------------------------->
7. Cannot cast from Float to String
value = (java.lang.String)(((java.lang.Float)field_bezahlt.getValue())); //$JR_EXPR_ID=17$
<------------------------------------------------------------->
8. Cannot cast from Date to String
value = (java.lang.String)(((java.util.Date)field_datum.getOldValue())); //$JR_EXPR_ID=10$
<------------------------------------------------------------->
9. Cannot cast from Float to String
value = (java.lang.String)(((java.lang.Float)field_netto.getOldValue())); //$JR_EXPR_ID=11$
<-------------------------------------------------------------->
10. Cannot cast from Float to String
value = (java.lang.String)(((java.lang.Float)field_mwst.getOldValue())); //$JR_EXPR_ID=12$
<------------------------------------------------------------->
11. Cannot cast from Integer to String
value = (java.lang.String)(((java.lang.Integer)field_rabatt.getOldValue())); //$JR_EXPR_ID=13$
<----------------------------------------------------------------->
12. Cannot cast from Integer to String
value = (java.lang.String)(((java.lang.Integer)field_zbid.getOldValue())); //$JR_EXPR_ID=14$
<--------------------------------------------------------------->
13. Cannot cast from Integer to String
value = (java.lang.String)(((java.lang.Integer)field_ausgewaehlt.getOldValue())); //$JR_EXPR_ID=16$
<---------------------------------------------------------------------->
14. Cannot cast from Float to String
value = (java.lang.String)(((java.lang.Float)field_bezahlt.getOldValue())); //$JR_EXPR_ID=17$
<---------------------------------------------------------------->
15. Cannot cast from Date to String
value = (java.lang.String)(((java.util.Date)field_datum.getValue())); //$JR_EXPR_ID=10$
<---------------------------------------------------------->
16. Cannot cast from Float to String
value = (java.lang.String)(((java.lang.Float)field_netto.getValue())); //$JR_EXPR_ID=11$
<----------------------------------------------------------->
17. Cannot cast from Float to String
value = (java.lang.String)(((java.lang.Float)field_mwst.getValue())); //$JR_EXPR_ID=12$
<---------------------------------------------------------->
18. Cannot cast from Integer to String
value = (java.lang.String)(((java.lang.Integer)field_rabatt.getValue())); //$JR_EXPR_ID=13$
<-------------------------------------------------------------->
19. Cannot cast from Integer to String
value = (java.lang.String)(((java.lang.Integer)field_zbid.getValue())); //$JR_EXPR_ID=14$
<------------------------------------------------------------>
20. Cannot cast from Integer to String
value = (java.lang.String)(((java.lang.Integer)field_ausgewaehlt.getValue())); //$JR_EXPR_ID=16$
<------------------------------------------------------------------->
21. Cannot cast from Float to String
value = (java.lang.String)(((java.lang.Float)field_bezahlt.getValue())); //$JR_EXPR_ID=17$
<------------------------------------------------------------->
Although while trying to convert Integer to String. I am using variables to create these fields so Im not sure why talend would even need to touch these fields? I would be happy if anyone has any suggestions of even a fix?
the log was taken from this guys error:
http://community.jaspersoft.com/questions/524190/problem-casting That solution does not seem to work in my case.
I now have the answer and am able to get it to work correctly. I will not be posting the answer instead I will give 10 points to anyone that has an answer that they think will work
Hint:
Its a casting error or a casting bug from talend. A cast needs to be made in jasper. But what is it? and how do you do it?
You could use the component tJasperReportExec as clean alternative to the tJasperOutput component. tJasperReportExec provides the possibilities like iReport to compile and fill a report based on a jrxml file and a database connection. There is no need to create an input flow and all of the problems with matching it to the internal field declaration of the report - this is what here causing the error. http://www.talendforge.org/exchange/index.php?eid=549&product=tos&action=view&nav=1,1,1