joe joseph
  • joe joseph

    joe joseph - 2011-09-07

    I use jasper report plugin for jsf beta 1.3 version and want to integrate a
    properties file for the internationalisation of the report. Everything is set
    normally but yet I still receive the java.util.MissingResourceException. Here
    is my java code and my xhtml file.


    <rich:panel style="width: 780px; height: 700px;">
                                            title="Bon de Commande"
                                            style="width: 750px; height: 650px;"
                                            <f:param name="REPORT_PARAMETERS_MAP" value="#{commandListPanel.reportViewer.parameters}"/>

    java code:

    public static ResourceBundle getMultilangueResourceBundle(){
            ResourceBundle resourceBundle = null;
            // Le FacesContext
            FacesContext context = FacesContext.getCurrentInstance();
            // Obtention du nom du Bundle de Message
            String messageBundleName = context.getApplication().getMessageBundle();
            // Locale à utiliser
            Locale locale = getLocale(context);
            // Obtention du ClassLoader
            ClassLoader loader = getClassLoader();
            // S'il n'ya pas de Bundle
            //if(messageBundleName == null || messageBundleName.trim().length() == 0)  ;
            resourceBundle = ResourceBundle.getBundle(messageBundleName, locale, loader);
            return resourceBundle;
         * Methode d'obtention de la locale du Contexte d'un Utilisateur
         * @param context   Contexte JSf
         * @return  Locale
        public static Locale getLocale(FacesContext context) {
            // Locale a retourner
            Locale locale = null;
            // Racine de l'arbre des composants
            UIViewRoot viewRoot = context.getViewRoot();
            // Si l'arbre n'est pas null
            if (viewRoot != null) {
                // On obtient la locale
                locale = viewRoot.getLocale();
                // Si la locale est nulle
                if(locale == null) return DEFAULTLOCALE;
                // Sinon
                else return locale;
            // Sinon
            else {
                // Obtention de la MAP de session
                Map<String, Object> sessionMap = context.getExternalContext().getSessionMap();
                // Si la MAP est nulle
                if(sessionMap == null || sessionMap.size() == 0) return DEFAULTLOCALE;
                // Recherche de la locale dans la MAP
                locale = (Locale) sessionMap.get(EStockViewHelper.SESSIONLOCALE_PARAMETER_NAME);
                // Si la locale est nulle
                if(locale == null) return DEFAULTLOCALE;
                // Sinon
                else return locale;
         * Methode d'obtention du ClassLoader
         * @return  le ClassLoader
        public static ClassLoader getClassLoader() {
            // Recherche du ClassLoader du Thread Courant
            ClassLoader loader = Thread.currentThread().getContextClassLoader();
            // Si ce ClassLoader est null (On Charge le ClassLoader Systeme)
            if (loader == null) loader = ClassLoader.getSystemClassLoader();
            // On retourne la ClassLoader
            return loader;

    I then pass the resource bundle as a parameter :

      //Paramètre de la session
            //Locale courante
            rParams.put("REPORT_LOCALE", EStockMultilangue.getLocale(FacesContext.getCurrentInstance()));
            //fichier de ressource
            rParams.put("REPORT_RESOURCE_BUNDLE", EStockMultilangue.getMultilangueResourceBundle() );

    Please can some one help? Or is the problem solved with the new version?

  • Alonso Dominguez

    Well, even though your code seems perfectly correct, you may get a
    "java.util.MissingResourceException" when trying to obtain a value from the
    resource bundle which hasn't been configured. If you take a look at the code
    for the "java.util.ResourceBundle" class you may find at method
    "getObject(String)" that exception being thrown when no value can't be found
    for a given key...

    Sorry, but with that information can't give more help, check your strings
    inside ResourceBundle and report... Also, in JSF 1.2 the preferred way to
    configure resource bundles is using the "resource-bundle" tag in faces-
    config.xml while the "MessagesBundle" should just be used to specify Faces'
    Messages (those regarding validation, for example). Using the former you can
    obtain "java.util.ResourceBundle" instances with current view locale by means
    of the method "Application.getResourceBundle(FacesContext, name)"


  • joe joseph

    joe joseph - 2011-09-07

    Hi Alonsoft,

    This issue has been solved. The problem was that I rather used the ireport
    REPORT_PARAMETERS_MAP to send the map of parameters, which did not work. I
    instead sent parameters one by one and then, the report could see the
    resourcebundle. Thank you.

  • Alonso Dominguez

    Glad you had found a way to solve it.

    I'm thinking about adding a "resourceBundle" attribute to the report related
    tags in order to address this in the future and prevent any missunderstanding.


  • joe joseph

    joe joseph - 2011-09-08

    yes it will be good.


Log in to post a comment.