Jump to content
Changes to the Jaspersoft community edition download ×

Compiling error with in java of IReport jrxml


danthehorn

Recommended Posts

Frustrated!

 

I have solved many issues trying to use Jasper by reading the forums or searching google but this one I don't know what is going on.

 

I take an IReport jrxml that compiles and then try to compile it using the java functions with zero luck. Why do I take an uncompiled JRXML IReport file?

 

That is because I need to create my own JRXML at runtime and thought maybe my JRXML was the issue. Well that did not prove to be the problem.

 

Note:

 

generatedJRXML and generatedPDF are variables that point to the files that must be produced. In this case generatedJRXML points to the valid (ONE FIELD REPORT) created by IReport.

 

code fragment:

 

private void generatePDF() throws Exception {

try {

File xml = new File(generatedJRXML);

JasperDesign jasperDesign = JRXmlLoader.load(xml);

JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

Map parameters = new HashMap();

Connection conn = DatabaseConnectionManager.getConnection();

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,

parameters, conn);

OutputStream output=new FileOutputStream(new File(generatedPDF));

JasperExportManager.exportReportToPdfStream(jasperPrint, output);

conn.close();

// JasperViewer.viewReport(jasperPrint);

} catch (Exception e) {

ReportError.toUser("Unable to gererate PDF", e);

throw e;

}

}

 

 

Exception:

 

Exception in thread "main" net.sf.jasperreports.engine.JRException: Error compiling report java source files : C:PentaIndustriescodePentaJobTrackingclassic_landscape_1188085947562_837366.java

at net.sf.jasperreports.engine.design.JRJavacCompiler.compileClasses(JRJavacCompiler.java:93)

at net.sf.jasperreports.engine.design.JRAbstractClassCompiler.compileUnits(JRAbstractClassCompiler.java:67)

at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:190)

at net.sf.jasperreports.engine.design.JRDefaultCompiler.compileReport(JRDefaultCompiler.java:105)

at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:212)

at com.penta.reports.jasper.GenerateAdhocTableReport.generatePDF(GenerateAdhocTableReport.java:50)

at com.penta.reports.jasper.GenerateAdhocTableReport.generateReport(GenerateAdhocTableReport.java:29)

at com.penta.reports.jasper.ViewAdhocReport.viewTableReport(ViewAdhocReport.java:9)

at com.penta.jobs.gui.dbaction.ReportTableResultsButton.main(ReportTableResultsButton.java:49)

Caused by: java.io.IOException: CreateProcess: javac -classpath C:PentaIndustriescodePentaJobTracking;C:PentaIndustriescodePentaJobTrackinglibappframework-0.50.jar;C:PentaIndustriescodePentaJobTrackinglibcommons-beanutils.jar;C:PentaIndustriescodePentaJobTrackinglibcommons-beanutils-bean-collections.jar;C:PentaIndustriescodePentaJobTrackinglibcommons-beanutils-core.jar;C:PentaIndustriescodePentaJobTrackinglibcommons-collections-3.2.jar;C:PentaIndustriescodePentaJobTrackinglibcommons-collections-testframework-3.2.jar;C:PentaIndustriescodePentaJobTrackinglibcommons-digester-1.8.jar;C:PentaIndustriescodePentaJobTrackinglibcommons-logging-1.1.jar;C:PentaIndustriescodePentaJobTrackinglibcommons-logging-adapters-1.1.jar;C:PentaIndustriescodePentaJobTrackinglibcommons-logging-api-1.1.jar;C:PentaIndustriescodePentaJobTrackinglibitext-2.0.4.jar;C:PentaIndustriescodePentaJobTrackinglibjasperreports-2.0.0-javaflow.jar;C:PentaIndustriescodePentaJobTrackinglibjazzy-core.jar;C:PentaInduâ€

at java.lang.ProcessImpl.create(Native Method)

at java.lang.ProcessImpl.<init>(Unknown Source)

at java.lang.ProcessImpl.start(Unknown Source)

at java.lang.ProcessBuilder.start(Unknown Source)

at java.lang.Runtime.exec(Unknown Source)

at java.lang.Runtime.exec(Unknown Source)

at net.sf.jasperreports.engine.design.JRJavacCompiler.compileClasses(JRJavacCompiler.java:62)

... 8 more

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Solved by dumping the JasperCompilerManager and replacing it with JRJdtCompiler class.

 

.

Method:

.

 

 

 

private void generatePDF() throws Exception {

try {

File xml = new File(generatedJRXML);

JasperDesign jasperDesign = JRXmlLoader.load(xml);

 

 

JRJdtCompiler compiler = new JRJdtCompiler();

JasperReport jasperReport = compiler.compileReport(jasperDesign);

 

// dump it JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

 

Map parameters = new HashMap();

 

Connection conn = DatabaseConnectionManager.getConnection();

 

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,

parameters, conn);

 

OutputStream output=new FileOutputStream(new File(generatedPDF));

 

JasperExportManager.exportReportToPdfStream(jasperPrint, output);

 

conn.close();

// JasperViewer.viewReport(jasperPrint);

} catch (Exception e) {

ReportError.toUser("Unable to gererate PDF", e);

throw e;

}

}

Link to comment
Share on other sites

  • 6 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...