bob007 Posted April 22, 2009 Share Posted April 22, 2009 Hi, I make my reports programmatically and I got this exception on compilation with JasperReports BUT when I export my report in .jrxml to try it with IReports its working (with a queryString).The error seem to occur because the compiler try to cast my report variable ($V{totalPriorite}) from Integer to String. What can cause this error ? I join the output .jrxml. Thank you,Philippe MY ERROR:_________________________________________________________________ net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:1. Cannot cast from Integer to String value = (java.lang.String)(((java.lang.Integer)variable_totalPriorite.getValue())); //$JR_EXPR_ID=18$ <------------------------------------------------------------------------>2. Cannot cast from Integer to String value = (java.lang.String)(((java.lang.Integer)variable_totalPriorite.getOldValue())); //$JR_EXPR_ID=18$ <--------------------------------------------------------------------------->3. Cannot cast from Integer to String value = (java.lang.String)(((java.lang.Integer)variable_totalPriorite.getEstimatedValue())); //$JR_EXPR_ID=18$ <--------------------------------------------------------------------------------->3 errors at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:195) at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:219) at JasperReportChartConstructor.compileReport(JasperReportChartConstructor.java:319) ... JAVA: ADDING THE VARIABLE_______________________________________________ JRDesignVariable variable = new JRDesignVariable(); variable.setName("totalPriorite"); variable.setResetType(JRDesignVariable.RESET_TYPE_GROUP); variable.setResetGroup(group); variable.setValueClass(java.lang.Integer.class); variable.setCalculation(JRDesignVariable.CALCULATION_COUNT); JRDesignExpression variableExpression = new JRDesignExpression(); variableExpression.setValueClass(java.lang.String.class); variableExpression.setText("$F{priorite}"); JRDesignExpression initialValueExpression = new JRDesignExpression(); initialValueExpression.setValueClass(java.lang.Integer.class); initialValueExpression.setText("new java.lang.Integer(0)"); variable.setExpression(variableExpression); variable.setInitialValueExpression(initialValueExpression); try { jasperDesign.addVariable(variable); } catch (JRException e) { // TODO Auto-generated catch block e.printStackTrace(); } Post Edited by bob007 at 04/22/2009 20:58 Link to comment Share on other sites More sharing options...
bob007 Posted April 23, 2009 Author Share Posted April 23, 2009 Ok its solved, It was a stupid error.I declared the wrong class for the using of the variable then the compiler was trying to cast Integer to Sring. its working now Regards,PhilippePost Edited by bob007 at 04/23/2009 18:26 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