I have ran into a problem when filling Jasper Reports that contain sub-reports. Jasper couldn't find by itself the sub-reports, although they were located into the same directory with the main report.
One way to solve this was to set the REPORT_FILE_RESOLVER parameter to the directory that contains the sub-reports, as describe here: http://forums.devshed.com/java-help-9/relative-path-for-subreport-in-jasperreport-309313.html
This created a problem because my code was packaged into a jar file that was part of an ear file and the approach described above wouldn't work, because I couldn't create a File object representing the sub-report directory to pass to the SimpleResolver class.
The best way I could find for doing this is to set the SUBREPORT_DIR parameter on the main report like this : "subreport_dir/".
Monday, February 14, 2011
Friday, February 4, 2011
Using Jasper templates inside a maven Java project
I have came across an issue with using compiled jasper templates inside a maven Java project. If I placed the jasper template inside the test resources for a project(src/test/resources) and then created a jasper report using that template in a test case everything worked smoothly. If however I moved the template in the project resources directory(src/main/java) and then tried to run the same test case I would get an
<nonFilteredFileExtensions>
<nonFilteredFileExtension>jasper</nonFilteredFileExtension> </nonFilteredFileExtensions>
java.io.StreamCorruptedException:invalid stream header: EFBFBDEF exception.
It turns out this happens because I had the resources filtering enabled in my project and Maven filtered the jasper file, producing in the target folder a file that was different than what I had in my resource folder. Hence, the stream corrupted exception. The solution to solve this is to configure the maven resources plug-in to exclude the .jasper file from filtering like this:<nonFilteredFileExtensions>
<nonFilteredFileExtension>jasper</nonFilteredFileExtension> </nonFilteredFileExtensions>
Subscribe to:
Posts (Atom)