Why is my jasper report compiling in iReports but not when i try to compile it using JasperCompileManager.compileReport(design)?

Im using iReport 5.0.0, jasperreports 4.7.1 and eclispe indigo. My objective is to use iReports to create the jrxml files and then use some java to populate my reports with the data that my clients will provide me at run time. When i try to use my ReportGenRunner.java class to execute my ReportGenerator.run() method i get the follow exception:


net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
calculator_Report1_1355934859559_852911: 225: unexpected char: '\' @ line 225, column 24.
1 error
at net.sf.jasperreports.compilers.JRGroovyCompiler.compileUnits(JRGroovyCompiler.java:113)
at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:201)
at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:240)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:496)
at com.ahsrcm.mobidash.jasper.java.reports.ReportGenerator.run(ReportGenerator.java:83)
at com.ahsrcm.mobidash.jasper.java.reports.runners.ReportGenRunner.main(ReportGenRunner.java:36)
Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
calculator_Report1_1355934859559_852911: 225: unexpected char: '\' @ line 225, column 24.
1 error
at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:296)
at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:143)
at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:113)
at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:125)
at org.codehaus.groovy.control.SourceUnit.addError(SourceUnit.java:337)
at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:99)
at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:71)
at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:236)
at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:158)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:814)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:511)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:487)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:464)
at net.sf.jasperreports.compilers.JRGroovyCompiler.compileUnits(JRGroovyCompiler.java:109)
... 5 more

I have been reading various related forums about what might cause this exception to be thrown and i have made changes to all my reports expressions so that any time a field/parameter/variables are converted into int or double primitive types.

The thing that is really confusing me is that line 225, column 24 does not contain an experssion in my jrxml. It is the end of one of my conditional style nodes. i have included the section of my jrxml that contains line 225



here is the method (run() ) that is where i try to use java to compile my report. the variables with '_' before them are my variables that i initalize in my ReportGenerator.java constructor.


Note: i do make changes to the jrxml using the java api, however my changes are not anywhere near where the exception is being throw. the report im running this code on has no subreports and i have triple checked that my images are in the right location and that the path string i use to find them are valid.


public void run() {
_logger.debug("pdf will be at: " + _pdfFileLoc);
JasperDesign design = JRXmlLoader.load(_jrxmlLoc);
JRDesignQuery query = new JRDesignQuery();
String initialMaseterQuery = design.getQuery().getText();
// sets all subreports data sources to the same as the master report
for ( JRBand jrb : design.getAllBands()) {
for (JRChild jrc : jrb.getChildren()) {
if (jrc instanceof JRDesignSubreport) {
JRDesignSubreport jrds = (JRDesignSubreport)jrc; 
String initialQuery = jrds.getDataSourceExpression().getText();
if ( initialMaseterQuery == initialQuery) {
JRDesignExpression jrde = new JRDesignExpression("((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).dataSource(" + _xPathQuery + ")");
_logger.warn("JRDesignSubreport now has datasource expression: " + jrde.getText());
} else {
throw new RuntimeException("subreport has different query than master report ... implement me!");
} else if (jrc instanceof JRDesignImage) {
JRDesignImage image = (JRDesignImage) jrc;
JRDesignExpression jre = new JRDesignExpression(_imageDir + "\\" + getImageName(image));
_logger.debug("image's new expression=" + image.getExpression().getText());
_logger.debug("compiling JasperReport");
JasperReport report = JasperCompileManager.compileReport(design);
JRXmlDataSource dataSource = new JRXmlDataSource(_xmlDataLoc);
_logger.debug("filling JasperPrint");
JasperPrint print = JasperFillManager.fillReport(report, _parms, dataSource);
JasperExportManager.exportReportToPdfFile(print, _pdfFileLoc + pdfName() );
} catch (JRException jre) { 
I have tired to use the depeciated JRJdtCompiler in place of JasperCompileManager and that did not work.

Does anyone have any ideas as to why this exception is being thrown where it is? has anyone else had a similiar issue with trying to compile jrxml that they have generated using iReport?

Thanks in advance or your input/solutions!



swarm357's picture
Joined: May 31 2012 - 9:48am
Last seen: 7 years 5 months ago
my jrxml appear to have not been added ... line 225 is the first instance of the "/conditionalStyle" node in one of my styles
swarm357 - 10 years 3 months ago
nevermind, i figured out my issue ... i didnt have my image path string formatted properly
swarm357 - 10 years 3 months ago

0 Answers:

No answers yet