Jump to content
We've recently updated our Privacy Statement, available here ×

Jasper fillReport method failed in struts


Recommended Posts

By: Lucho - rebprotizer

Jasper fillReport method failed in struts

2006-07-12 03:18

I would like to create a PDF file in a struts action, but the fillReport method doesn't work and any exception is catched.

 

My source here :

logger.info("Etape 1");

String reportName = "C:/DRA-Reports/maquette_REC02.jasper";

logger.info("Etape 2");

String pdfName = "C:/DRA-Reports/namePdf.pdf";

logger.info("Etape 3");

 

try {

JasperPrint jasperPrint = JasperFillManager.fillReport(reportName, new HashMap(), new JREmptyDataSource());

} catch (JRException e) {

e.printStackTrace();

} catch (RuntimeException e) {

e.printStackTrace();

} catch (Exception e) {

e.printStackTrace();

}

logger.info("Etape 4");

JasperExportManager.exportReportToPdfFile(jasperPrint, pdfName);

 

When I execute my action, i have an error : null, but any exception is catched. So i didn't know why the Etape 4 logger is not displayed.

 

I have replace reportName by : this.getClass().getClassLoader().getResourceAsStream("maquette_REC02.jasper") for a relative path, but I have the same error.

 

I have the feel that the fillReport crashed the system but I don't know why.

 

Can you help me please, it's very urgent.

 

Thank you.

 

Luc LABBE

 

 

By: teepee - tpatzner

RE: Jasper fillReport method failed in struts

2006-07-18 18:09

I tried your code in a struts action and it worked for me. BTW, I had to move this line of code 'JasperExportManager.exportReportToPdfFile(jasperPrint, pdfName);' inside the try block because that is where you declare your jasperPrint object!

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...