[#2841] - JasperFillManager.fillReportToFile works only with relative paths

Category:
Bug report
Priority:
High
Status:
New
Project: Severity:
Major
Resolution:
Open
Component: Reproducibility:
Always
Assigned to:

Using a full filename (like C:\temp\test), the method JasperFillManager.fillReportToFile() raises an error:
Error saving file : C:\temp\C:\temp\test.jrprint

String _reportsFileBaseName = "C:\\temp\\test"; // filename without extension
JasperDesign jasperDesign = getJasperDesign();
JRXmlWriter.writeReport( jasperDesign, _reportsFileBaseName + ".jrxml", "UTF-8" );
JasperCompileManager.compileReportToFile( jasperDesign, _reportsFileBaseName + ".jasper" );
JasperFillManager.fillReportToFile( _reportsFileBaseName + ".jasper", null, dataSource );

Using relative filename works, but I don't want to store the files in the applications directory (or sub directory).

v5.0.0
JasperFillManager
rinse's picture
268
Joined: Jul 12 2011 - 6:40am
Last seen: 1 week 18 hours ago

3 Comments:

#1
  • Priority:Normal» High
  • Severity:Minor» Major
  • Assigned:nobody»
#2
  • Assigned:» anonymous

Editting the bugreport failes: I get an error: The referenced entity (user: 306070) is invalid.

***
EDIT: It can't work with subdirectories

When I give reportsFileBaseName a relative subdir like this:
String _reportsFileBaseName = "temp\\reports\\test"

JasperFillManager.fillReportToFile() raises an error:
Error saving file : temp\reports\temp\reports\test.jrprint
the files temp\reports\test.jrxml and temp\reports\test.jasper are created as expected

****

#3

I found a workarround. The .jasper file gets an internal name derived from the filename. When the filename contains sub-directories, the name of the jasper report also gets sub-directories. The name property is used to create the .jrprint filename. When the name contains sub-directories ot doubles the parent directorie in its filname.

By setting the name of jasperDesign with the filename (without parent directories) it works.
So in the case above jasperDesign.setName( "test" ); will fix this issue

Feedback