开发者

Program not finding JasperReports resource bundle (.properties file)

I'm trying to use JasperReports in my JSF 2.开发者_JAVA百科0 application. I'm using NetBeans 6.9.1, mojarra 2.0.3, and PrimeFaces 2.2.RC2 as well. I've developed a trial report in iReport 3.7.6. I've changed one static label to a text field getting is value from a resource bundle/.properties file. The report runs as expected from iReport, but when I try to run it from my program I'm getting the following error:

SEVERE: javax.faces.FacesException: #{userReportBean.runReport}: java.util.MissingResourceException: Can't find bundle for base name Bundle, locale en_US

The report runs fine without reference to the bundle. Is my only solution to make the static labels parameters and pass them in at the time the report is run? Or is there a way to tell the report where to find the .properties file when the report isn't run from iReport?


This means that it cannot find any of the files Bundle_en_US.properties, Bundle_en.properties or Bundle.properties in the classpath. You need to place it in the classpath which JasperReports has access to.

Note that when you've actually placed them inside a package, then you need to specify that in the basename as well. E.g. com.example.Bundle for the case that they're actually placed in a package named com.example.


You have to place the bundle in the same folder where you have your .jrxml file. If your reports is named "myreport.jrxml", you need to create a folder called "myreport_Bundle".

Inside that folder places your properties file:

  • myreport.properties (default file)
  • myreport_en_US.properties (american English)
  • myreport_es_ES.properites (spanish from Spain)
  • etc

You also need to set the properties "Resources Bundle" in your report (via iReport, for instance). The value of the property is the same as the name of the file, in this case, "myreport" (no need to add "_Bundle").

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜